> require in php ~ Online tutorial

require in php

The require() function is identical to include() except that is handle error differently.
The the function include() generates a warning(but the script continue execution) while the require() function generates a fatal error (and script stop)
Syntax
include "function name";
Example
vars.php


<?php
$color='red';
$fruit='apple';
echo $fruit."color is".$color"
?>
test.php

<?php
echo "a $color $fruit"
// include 'vars.php
require'vars.php'
echo "a $color $fruit"
?>
Output:



Please Give Us Your 1 Minute In Sharing This Post!
Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Powered By: BloggerYard.Com

0 comments: