php basics
PHP require
PHP require is used to import a PHP file.
PHP require and include usage can be said to be almost the same, the biggest difference is that require will stop the operation of the program when an error occurs, while include will only generate a warning, but continue to execute the subsequent code, so if you want When the program that requires comes in, it can stop working, so use require!
PHP require syntax example
The first file: test1.php
<?php
$var='456';
?> The
second file: test2.php
<?php
require'test1.php'; // Import test1.php
echo '123'.$ var; // output result
?>
Output result: 123456<?php
$var='456';
?> The
second file: test2.php
<?php
require'test1.php'; // Import test1.php
echo '123'.$ var; // output result
?>
Suppose we have prepared two php files, test1.php and test2.php, and then import test1.php into test2.php in require, and finally output the variables . Note that the two php programs are respectively For different files, not the same document.
Post a Comment
0 Comments