How to declare print function in PHP
I am learning with the PHP language and need to have the basic print() function, the function would be such that it should print the value given in the program also provide me some information related to it.This would be really helpful for me, as i will be implementing this in my project file.
Thanks in Advance
Re: How to declare print function in PHP
The print() function is not actually a function, so you are not required to use parentheses with it.
Tip: The print() function is slightly slower than echo().
PHP Code:
<?php
$str = "Who's Kai Jim?";
print $str;
print "<br />";
print $str."<br />I don't know!";
?>
Re: How to declare print function in PHP
If you wanted to just print the value of a variable (which is what you seem to be doing) then there is no need to write the quotes around the value you declare. You will be needed to put quotes around a variable if you were trying to interpolate its value into a string, so:
PHP Code:
$var = 'World';
print "Hello $var!";
Re: How to declare print function in PHP
If the dialog box is the same one when you hit Ctrl+P on the keyboard (which i'm sure it is), then it is best if left that way. It probably isn't the quotes since nothing outside your php brackets would cause it not to print. rather more likely your variable doesn't exist. This allows users to pick the printer they want if they have more than one printer to choose from and it also allows them to modify the page margins, how many pages they want to print, etc.