Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
Beginner PHP Tutorial - 10 - print
Description
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:
More from User
05:24
Beginner PHP Tutorial - 11 - Output HTML Using echo_print
Videos
02:18
Beginner PHP Tutorial - 10 - print
Videos
04:09
Beginner PHP Tutorial - 9 - echo
Videos
04:52
Beginner PHP Tutorial - 8 - Indentation
Videos
06:06
Beginner PHP Tutorial - 7 - The php.ini File
Videos
05:00
Beginner PHP Tutorial - 6 - The phpinfo Function
Videos
Related Videos
00:29
Développer un site web en PHP, MySQL et Javascript PDF: jQuery, CSS3 et HTML5.
Shalyutinav
00:08
READ ONLINE Learning PHP MySQL JavaScript With jQuery CSS HTML5 Learning Php Mysql Javascript
Emildeluxe 1o
00:05
Learning PHP MySQL & JavaScript: With jQuery CSS & HTML5 (Learning Php Mysql Javascript Css
Majhoul 0000000
00:30
[P.D.F] Learning PHP, MySQL JavaScript: With jQuery, CSS HTML5 (Learning Php, Mysql,
Alisha Khan
00:07
[PDF Download] Programming For Beginner's Box Set: Learn HTML HTML5 & CSS3 Java PHP & MySQL
Challenbec
00:40
[Read] Learning Php, MySQL & JavaScript: With Jquery, CSS & Html5 For Kindle
jayquintana63