Lunarpages Web Hosting
 
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read Web Directory

Go Back   Webmaster Forum > Designing and Developing Websites > Programming > PHP / MySQL

PHP / MySQL Discussions and help on PHP and MySQL.

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-04-2007, 05:17 AM
clookid clookid is offline
WMG Newcomer
 
Join Date: Mar 2007
Posts: 21
iTrader: (0)
clookid is on a distinguished road
Default Strings

Strings

Strings are text, pure and simple. There's two ways of storing strings, inside single quotes and double-quotes. Using "double-quotes" allows you to use special characters like \n for a newline. The backslash character marks the next character as special, though the only characters you can backslash in 'single-quoted' strings are \' (a single quote) and \\ (a backslash).

Some other special characters (for double-quoted strings)

PHP Code:
t


TAB

n


newline



carriage-return. In DOS text-files, a new line is \r\n, though in practice in Windows you can get away with UNIX format, which is just \n

PHP Code:
$


$

'


'

"



The most important difference between single and double-quoted strings is that double-quoted strings can contain variable names:

PHP Code:
$foo 'This doesn\'t work'// Oh yes it does!
$foo "Matt's second line also works";

$age 18;
echo 
'Bob is $age'// prints "Bob is $age"
echo "Bob is $age"// prints "Bob is 18" 
Check out the manual for more string stuff -- this is generally enough to get along with in daily use.

This tutorial was written by another one of my friends, if you would like to use this tutorial please send me a PM!
Reply With Quote
Sponsored Links
Register and sign in to hide this ad block

  #2 (permalink)  
Old 03-10-2007, 10:27 PM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default

Can I store this tags in mysql table? How to fetch it with this effects again on the screen?

Any help will be appreciated.
Reply With Quote
  #3 (permalink)  
Old 03-19-2007, 11:03 AM
blokey blokey is offline
WMG Resident Alien
 
Join Date: Mar 2007
Posts: 93
iTrader: (0)
blokey is on a distinguished road
Default

Except strings aren't necessarily just text. They can contact any arbitrary string of bytes.
Reply With Quote
  #4 (permalink)  
Old 03-19-2007, 11:06 AM
blokey blokey is offline
WMG Resident Alien
 
Join Date: Mar 2007
Posts: 93
iTrader: (0)
blokey is on a distinguished road
Default

Quote:
Originally Posted by technoguy View Post
Can I store this tags in mysql table? How to fetch it with this effects again on the screen?
Of course.

I'm not quite sure what you mean about fetching it again. You can use htmlentities() to convert special characters to entities to avoid dumping HTML out to the browser.
Reply With Quote
  #5 (permalink)  
Old 03-19-2007, 01:09 PM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default

Yes you have got me right. I have stored html tags in mysql table's field. I want to print content of table with html formatting. Can I use htmlentities for this? Can I do it with simple echo ?
Reply With Quote
  #6 (permalink)  
Old 03-19-2007, 01:25 PM
blokey blokey is offline
WMG Resident Alien
 
Join Date: Mar 2007
Posts: 93
iTrader: (0)
blokey is on a distinguished road
Default

htmlentities will convert characters such as < and > to their respective HTML entities (&lt; and &gt; ) so the browser will literally display < and > and not parse it as HTML markup. If you have HTML stored in the database and want to send it straight to the browser, just echo or print it.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT. The time now is 06:08 AM.



Freelance Web Designers
Work At Home Forum
Ad Marketplace
Online Deals and Bargains
HostGator Hosting Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0