此内容来自第三方平台 (Dailymotion)。如果此视频侵犯了您的版权,请使用 立即删除 工具。
Beginner PHP Tutorial - 10 - print
描述
print
(PHP 4, PHP 5)
print — Output a string
Description
int print ( string $arg )
Outputs arg.
print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.
Parameters
arg
The input data.
Return Values
Returns 1, always.
Examples
Example #1 print examples
"foo");
print "this is {$bar['value']} !"; // this is foo !
// Using single quotes will print the variable name, not the value
print 'foo is $foo'; // foo is $foo
// If you are not using any other characters, you can just print variables
print $foo; // foobar
print
Notes
Note: Because this is a language construct and not a function, it cannot be called using variable functions.
See Also
echo - Output one or more strings
printf() - Output a formatted string
flush() - Flush system output buffer
Heredoc syntax
add a note add a note
User Contributed Notes 14 notes
up
down
22 user at example dot net 7 years ago
Be careful when using print. Since print is a language construct and not a function, the parentheses around the argument is not required.
In fact, using parentheses can cause confusion with the syntax of a function and SHOULD be omited.
Most would expect the following behavior:
But since the parenthesis around the argument are not required, they are interpretet as part of the argument.
This means that the argument of the first print is
("foo") && print("bar")
and the argument of the second print is just
("bar")
For the expected behavior of the first example, you need to write:
(PHP 4, PHP 5)
print — Output a string
Description
int print ( string $arg )
Outputs arg.
print is not actually a real function (it is a language construct) so you are not required to use parentheses with its argument list.
Parameters
arg
The input data.
Return Values
Returns 1, always.
Examples
Example #1 print examples
"foo");
print "this is {$bar['value']} !"; // this is foo !
// Using single quotes will print the variable name, not the value
print 'foo is $foo'; // foo is $foo
// If you are not using any other characters, you can just print variables
print $foo; // foobar
Notes
Note: Because this is a language construct and not a function, it cannot be called using variable functions.
See Also
echo - Output one or more strings
printf() - Output a formatted string
flush() - Flush system output buffer
Heredoc syntax
add a note add a note
User Contributed Notes 14 notes
up
down
22 user at example dot net 7 years ago
Be careful when using print. Since print is a language construct and not a function, the parentheses around the argument is not required.
In fact, using parentheses can cause confusion with the syntax of a function and SHOULD be omited.
Most would expect the following behavior:
But since the parenthesis around the argument are not required, they are interpretet as part of the argument.
This means that the argument of the first print is
("foo") && print("bar")
and the argument of the second print is just
("bar")
For the expected behavior of the first example, you need to write:
关键词与标签
相关视频
Développer un site web en PHP, MySQL et Javascript PDF: jQuery, CSS3 et HTML5.
Shalyutinav
READ ONLINE Learning PHP MySQL JavaScript With jQuery CSS HTML5 Learning Php Mysql Javascript
Emildeluxe 1o
Learning PHP MySQL & JavaScript: With jQuery CSS & HTML5 (Learning Php Mysql Javascript Css
Majhoul 0000000
[P.D.F] Learning PHP, MySQL JavaScript: With jQuery, CSS HTML5 (Learning Php, Mysql,
Alisha Khan
[PDF Download] Programming For Beginner's Box Set: Learn HTML HTML5 & CSS3 Java PHP & MySQL
Challenbec
[Read] Learning Php, MySQL & JavaScript: With Jquery, CSS & Html5 For Kindle
jayquintana63