📜  php print - PHP (1)

📅  最后修改于: 2023-12-03 15:18:20.811000             🧑  作者: Mango

PHP print - PHP

Introduction

PHP print statement is used to display output to the web page. It is a built-in PHP function that can be used to print text, variables, and HTML content. The print statement has one required argument which is the text to be displayed, and it returns a boolean value, which is true if the output is successful, and false otherwise.

Syntax
print(expression);
Parameters
  • expression: The expression to display. This parameter can be a string, a variable, or a combination of both.
Example
<?php
$name = "John Doe";
print("Hello, ".$name);
?>

Output:

Hello, John Doe
Modify Output

You can also modify the output of the print statement using HTML tags, as shown below:

<?php
$name = "John Doe";
print("<h1>Hello, ".$name."</h1>");
?>

Output:

Hello, John Doe
Conclusion

In conclusion, the PHP print statement is a useful function that can be used to display output to the web page. It is easy to use and can be modified to include HTML tags for advanced output.