Results 1 to 9 of 9

Thread: I dont now anything about php

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    25

    I dont now anything about php

    but after looking at a lot of code while im bored i notice

    print and echo

    It looks like they do the same thing?

    Im just wondering why print gets used sometimes and echo the other times?


    I think im going to start to learn php

    It looks like it could be fun
    Last edited by Jazza; Jan 24th, 2007 at 11:14 PM.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: I dont now anything about php

    print is lame, echo is cool.

    For a more detailed explanation of similiar usefulness:
    http://www.faqts.com/knowledge_base/...l/aid/1/fid/40

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: I dont now anything about php

    Some people say that using 'Print' works better, but 'echo' does the same exact thing. I Use 'echo' more then 'print'.
    My usual boring signature: Something

  4. #4
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: I dont now anything about php

    To add to pengates post, this article refereces the same faq.

    http://us3.php.net/manual/en/function.print.php
    http://us3.php.net/manual/en/function.echo.php

  5. #5
    Junior Member
    Join Date
    Jan 2007
    Posts
    16

    Re: I dont now anything about php

    Echo is the thing that i learned first so i say 4/0 for echo!!
    echo is actually a statement that shows html code so
    if you do
    Code:
    echo "*BURP*<br><BR>html isnt so cool as echo and you know it!!"
    then you get
    *BURP*

    html isnt so cool as echo and you know it


    it is handy because you can apply variables to it such as
    Code:
     $name = "freakybleep"
    echo ("you are a freak $name and you know it")
    then you get
    you are a freak freakybleep and you know it
    understand?

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: I dont now anything about php

    Quote Originally Posted by roelor
    Echo is the thing that i learned first so i say 4/0 for echo!!
    echo is actually a statement that shows html code so
    if you do
    Code:
    echo "*BURP*<br><BR>html isnt so cool as echo and you know it!!"
    then you get
    *BURP*

    html isnt so cool as echo and you know it


    it is handy because you can apply variables to it such as
    Code:
     $name = "freakybleep"
    echo ("you are a freak $name and you know it")
    then you get
    you are a freak freakybleep and you know it
    understand?
    Variables can be embedded in any double quoted string and it is generally not a good idea to spit out HTML using echo.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: I dont now anything about php

    Quote Originally Posted by visualAd
    Variables can be embedded in any double quoted string and it is generally not a good idea to spit out HTML using echo.
    yeah. You should close your PHP then open it again...

    PHP Code:
    ...
    while ($array = mysql_fetch_array($query)) {
    ?>
    HTML CODE HERE
    MORE HERE

    LETS PUT SOME MORE HERE...
    <?PHP

    ...
    My usual boring signature: Something

  8. #8
    Junior Member
    Join Date
    Jan 2007
    Posts
    16

    Re: I dont now anything about php

    yeah u guys are right but for a short sentance like the one i wrote is the echo string MUCH better els you get this
    PHP Code:
    hello <? echo $name; ?> how are you last time you visited was on <? echo $date; ?>
    wouldnt you get sick of that method perticulary when you have more php then html

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: I dont now anything about php

    That's the way you should do it. If you have more PHP than HTML you are doing something wrong.

    All your processing should be at the top of the script before you output any HTML. The HTML should then appear at the bottom and should contain only simple display logic. It should be in such a format that all the HTML could be removed and placed in a separate file to be included.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width