Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-20-2003, 02:55 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
Single Quote vs. Double Quote

I recently ran into this little bit of info when working on some code to replace line breaks in a string with some HTML code....

When quoting attributes PHP (Perl as well) treats values wrapped by single quotes as there face value, it will not replaced variables or treat special characters how you would expect. When using double quotes variables are replaced and special character sets are treated normaly.

Here is an example:

PHP Code:
<?
$FeaturesFixed 
"this
is
the
features
code"
;

$FeaturesFixed ereg_replace ("\n""<li>"$Features);

echo(
" <li>$FeaturesFixed");
?>
Code:
<li>this
<li>is
<li>the
<li>features
<li>code
now with single quotes

PHP Code:
<?
$FeaturesFixed 
ereg_replace ('\n''<li>'$Features);

echo(
" <li>$FeaturesFixed");
?>
Code:
<li>this
is
the
features
code
Admin is offline   Reply With Quote
Reply

Bookmarks

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Mortgage.cpp verdell32 Standard C, C++ 7 10-23-2004 06:50 AM
Double quotes in fwrite NirTivAal PHP 8 12-08-2003 08:13 AM
Help Please (Need help by Monday 29th of September!) CoW Standard C, C++ 12 10-02-2003 09:38 AM
How do I embed a single image in the bg of a table w/o tiling? sde HTML, XML, Javascript, AJAX 4 08-27-2002 08:36 AM


All times are GMT -8. The time now is 12:11 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting