php: Detailed explanation of echo usage examples
Official manual description:
Definition and Usage
Definition and Usage
The echo() function outputs one or more strings.
echo()The function is used to output one or more strings.
Syntax
Syntax
echo(strings)
Parameter Parameter Description
strings Required. One or more strings to be sent to the output
Required parameters . Specify one or more strings that need to be sent to the results
Tips and Notes
Tips and Notes
Note: The echo() function is not actually a function, so you are not required to use parentheses with it. However, if you want to pass more than one parameter to echo(), using parentheses will generate a parse error.
Note: The echo() function is not a real function, so you don’t have to Go use it. If you want to pass more than one argument to the echo() function, using parentheses "()" will generate 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 has the following shortcut syntax. For details, see: 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 will be:
The above code will output the following results:
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 will be:
The above code will output the following result:
This text spans multiple lines.
Case 3
<?php echo 'This ','string ','was ','made ','with multiple parameters'; ?>
The output of the code above will be:
The above code will output the following results:
This string was made with multiple parameters
Case 4
Difference of single and double quotes. Single quotes will print the variable name, not the value:
Difference between single quotes (') and double quotes ("). Single quotes will print Output variable name instead of the value of the variable:
<?php $color = "red"; echo "Roses are $color"; echo "<br />"; echo 'Roses are $color'; ?>
The output of the code above will be:
The above code will output the following results:
Roses are redRoses are $color
Case 5
Shortcut syntax:
Shortcut (shortcut) syntax:
<html> <body> <?php $color = "red"; ?> <p>Roses are <?=$color?></p> </body> </html>
The above is the detailed content of php: Detailed explanation of echo usage examples. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
