Results 1 to 4 of 4
-
3rd Nov 2010, 02:00 PM #1OPMember
php string - heredoc syntax
its very basic, but not many use it ..
PHP Code:<?php
$var1 = "KWWHunction";
$string1 = <<< EOD
I am a bot <br />
I <3 $var1 <br />
I need not be escaped , let's test <br />
EOD;
echo $string1;
?>
Advantages : no need to escape quotes in the string itself..
I donno about the disadvantages.. if you know any , please post it heredesiboy Reviewed by desiboy on . php string - heredoc syntax its very basic, but not many use it .. <?php $var1 = "KWWHunction"; $string1 = <<< EOD I am a bot <br /> I <3 $var1 <br /> I need not be escaped , let's test <br /> EOD; Rating: 5Coding Horror Fan
I don't read PM's frequently .
-
4th Nov 2010, 01:05 AM #2MemberWebsite's:
Doxsters.netThe only reason I don't use it is that it looks damn wierd compared to the rest of PHP syntax, and kinda throws me off.
Need a Designer/Web Developer? Click Me
MSN: PM me for it.
Email(Preferred):timtamboy63@gmail.com
"Power Corrupts. Absolute Power Corrupts Absolutely"
-
9th Nov 2010, 05:44 AM #3MemberWebsite's:
rapidgen.neti find it a lot easier to use, compared to breaking in and out of html<->php all the time, which to me looks messy.
i haven't found any disadvantage to EOD yet, apart from when I wanted to run a php function from inside the EOD area, i had to put braces around the code {$phpobject->run()}, other than that it seems to work smoothly for just about every scenario i could imagine.
http://www.php.net/manual/en/languag...syntax.heredoc
-
16th Nov 2010, 05:15 PM #4OPMember
btw..
PHP Code:<?php
$var1 = "KWWHunction";
$string1 = <<< KWWHUNCTION
I am a bot <br />
I <3 $var1 <br />
I need not be escaped , let's test <br />
KWWHUNCTION;
echo $string1;
?>Coding Horror Fan
I don't read PM's frequently .
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Syntax Error
By Qoo in forum WordpressReplies: 0Last Post: 7th Jun 2012, 02:23 PM -
mysql syntax error
By gamma in forum Web Application/Script SupportReplies: 8Last Post: 18th Apr 2012, 04:11 AM -
Extracting data from a string
By pankaj in forum Web Development AreaReplies: 38Last Post: 6th Jul 2010, 01:38 PM -
[c#] Get String In between strings
By jayfella in forum Web Development AreaReplies: 3Last Post: 16th Jun 2010, 11:23 PM -
Syntax Error
By Ryan in forum phpBBReplies: 3Last Post: 12th Feb 2009, 10:24 PM
themaRegister - register to forums...
Version 3.54 released. Open older version (or...