Activity Stream
48,167 MEMBERS
6799 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Member

    Thumbs up 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;
    ?>
    EOD stands for end of data

    Advantages : no need to escape quotes in the string itself..

    I donno about the disadvantages.. if you know any , please post it here
    desiboy 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: 5
    Coding Horror Fan
    I don't read PM's frequently .

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    Doxsters.net
    The 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"

  4.     
    #3
    Member
    Website's:
    rapidgen.net
    i 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

  5.     
    #4
    Member
    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;
    ?>
    will work
    Coding Horror Fan
    I don't read PM's frequently .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Syntax Error
    By Qoo in forum Wordpress
    Replies: 0
    Last Post: 7th Jun 2012, 02:23 PM
  2. mysql syntax error
    By gamma in forum Web Application/Script Support
    Replies: 8
    Last Post: 18th Apr 2012, 04:11 AM
  3. Extracting data from a string
    By pankaj in forum Web Development Area
    Replies: 38
    Last Post: 6th Jul 2010, 01:38 PM
  4. [c#] Get String In between strings
    By jayfella in forum Web Development Area
    Replies: 3
    Last Post: 16th Jun 2010, 11:23 PM
  5. Syntax Error
    By Ryan in forum phpBB
    Replies: 3
    Last Post: 12th Feb 2009, 10:24 PM

Tags for this Thread

BE SOCIAL