Results 1 to 4 of 4

Thread: Information on php echo

  1. #1
    Join Date
    May 2008
    Posts
    53

    Information on php echo

    echo() is not actually a function (it is a language construct), so you are not required to use parentheses with it. echo() (unlike some other language constructs) does not behave like a function, so it cannot always be used in the context of a function. Additionally, if you want to pass more than one parameter to echo(), the parameters must not be enclosed within parentheses.

    echo() also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. This short syntax only works with the short_open_tag configuration setting enabled.

    You can echo array values or use these values directly in your statements.

    Say you have an array:

    $colors=array('good ', 'very good', 'best');

    The above is equivalent to:

    $colors[0]="good";
    $colors[1]="very good";
    $colors[2]="best";

    To echo, simply do:

    echo $colors[0]; // outputs good
    echo $colors[1]; // outputs very good
    echo $colors[2]; // outputs best

  2. #2
    Join Date
    Dec 2008
    Posts
    69

    Re: Information on php echo

    echo() function is slightly faster than print(). It can output all types of data and multiple outputs can be made with only one echo () command.

    Example
    <?php echo "welcome to my website "; ?>

  3. #3
    Join Date
    Dec 2008
    Posts
    29

    Re: Information on php echo

    <? php function hello_world ()
    ( echo 'Hello World! " ; ) >

    To display Hello World! Anywhere in your code, you will only have to type this:

    <? php hello_world () / / calls the "hello_world" which will display "Hello World! ?>

  4. #4
    Join Date
    Nov 2008
    Posts
    70

    Re: Information on php echo

    You should take care while using HTML code or any other string that includes quotes. Echo uses quotes to define the beginning and end of the string, Escape your quotes that are within the string with a backslash. To escape a quote just place a backslash directly before the quotation mark.

Similar Threads

  1. Need to know about Kyocera Echo
    By Corwinn in forum Portable Devices
    Replies: 4
    Last Post: 15-02-2011, 05:35 PM
  2. Replies: 3
    Last Post: 05-09-2009, 01:41 PM
  3. How To Use Echo statement in PHP
    By Pikachoo in forum Software Development
    Replies: 2
    Last Post: 18-03-2009, 08:31 AM
  4. Set colors in echo
    By revolucioncg in forum Software Development
    Replies: 3
    Last Post: 14-02-2009, 09:53 PM
  5. Sound has an echo
    By Tominfl in forum Windows Software
    Replies: 2
    Last Post: 15-09-2008, 04:35 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,656,441,675.16381 seconds with 17 queries