Php:echo usage Examples

Source: Internet
Author: User
Tags parse error
Official Manual Description:

Definition and Usage
Definition and usage
The Echo () function outputs one or more strings.
The Echo () function works by outputting one or more strings.
Syntax
Grammar
Echo (Strings)
Parameter parameter Description description
Strings Required. One or more strings to is sent to the output
Necessary parameters. Specify one or more strings that need to be sent to the result
Tips and Notes
Tips and attention points
Note:the Echo () function is a function of actually a, so that is not the required to use parentheses with it. However, if you want to pass more than one parameter to echo (), using parentheses would generate a parse error.
Note: the Echo () function is not a real function, so you do not have to use it necessarily. If you want to pass more than one parameter to the Echo () function, then using the parentheses "()" will produce an error.
Tip:the Echo () function is slightly faster than print ().
Tip: the Echo () function is equivalent to a simplified version of the print () function.
Tip:the Echo () function has the following shortcut syntax. See Example 5.
Tip: the Echo () function contains the following handy notation. See details: Case 5.
Example 1
Case 1

<?php $str = "Who's Kai Jim?"; Echo $str; echo "<br/>"; echo $str. " <BR/>i don ' t know! ";? >

The output of the code above would be:
The code above will output the following result:
Who ' s Kai Jim? Who ' s Kai Jim? I don ' t know!

Case 2

<?php echo "This Textspans multiplelines."; ?>

The output of the code above would be:
The code above will output the following result:
This text spans multiple lines.

Case 3

<?php echo ' This ', ' string ', ' is ', ' made ', ' with multiple parameters ';?>

The output of the code above would be:
The code above will output the following result:
This string is made with multiple parameters

Case 4
Difference of single and double quotes. Single quotes would print the variable name, not the value:
Distinguish between single quotation marks (') and double quotation marks ("). Single quotes will output the variable name, not the value of the variable:

<?php $color = "Red"; echo "Roses is $color"; echo "<br/>"; Echo ' Roses is $color ';?>

The output of the code above would be:
The code above will output the following result:
Roses is redroses is $color

Case 5
Shortcut Syntax:
Shorthand (shortcut) syntax:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.