亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home php教程 php手冊 The difference between echo(), print(), print_r(), var_dump() in php

The difference between echo(), print(), print_r(), var_dump() in php

Oct 19, 2016 am 10:19 AM
print()

echo() function: Output one or more strings. In fact, it is not a function, so there is no need to use parentheses on it, just use echo. However, if you wish to pass more than one argument to echo(), using parentheses will generate a parsing error. The echo() function is slightly faster than print(). When echo outputs multiple strings, separate them with commas.

For example 1: (Write the value of the string variable $str into the input)

$str="hello world!";

echo $str;

?>

Run result: hello world!

Example 2: (echo outputs multiple strings)

echo 'a','b','c';

print() function: Output one or more strings. Like echo, it is not actually a function. Print has a return value, but echo does not. When its execution fails, it returns false, and if it succeeds, it returns true. The speed is slightly slower than echo. Only the values ??of simple type variables can be printed out, such as int and string.

For example 1: (Write the value of the string variable $str to the output)

$str="hello world!";

print $str;

?>

print_r() function: can print out the value of complex type variables. Print_r() can be used to print out the entire array content and structure, displaying keys and elements in a certain format. In fact, it is not only used for printing, but for printing easy-to-understand information about variables.

For example 1: (Print array $age)

$age=array(18,20,24);

print_r($age);

?>

Run result: Array ( [0] => 18 [1] => 20 [2] => 24 )

var_dump() function: determines the type and length of a variable, and outputs the value of the variable. If the variable has a value, the value of the variable is output, and the data type is returned. This function displays structural information about one or more expressions, including the expression's type and value. Arrays will expand values ??recursively, showing their structure through indentation.

Example 1:

$age=array(18,20,24);

var_dump($age);

?>

Run result: array(3) { [0]=> int(18) [1]=> int(20) [2]=> int(24) }

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72