include() will throw a warning and require() will throw a fatal error if the file is missing.
Tag Archives: Functions
echo() vs print()
print() returns a value much like a normal function would but echo() does not
echo() runs faster than print()
Echo can take multiple parameters where as print cannot
Difference Between echo() and print() PHP
print() returns a value much like a normal function would but echo() does not
echo() runs faster than print()
Echo can take multiple parameters where as print cannot
Difference Between Include() and require() PHP
include() will throw a warning and require() will throw a fatal error if the file is missing.
Difference Between Include() and Include_once() PHP
Both functions includes the given file but Include_once() checks whether the given file is already included .As the name suggests , the file will be included only once .
session_destroy()
It delete/destroy existing session
<?php
session_start();
$_SESSION[‘lan’]=”PHP Code”;
echo $_SESSION[‘lan’] ;
session_destroy();
?>
session_start()
It start new or resume existing session
<?php
session_start();
$_SESSION[‘lan’]=”PHP Code”;
echo $_SESSION[‘lan’] ;
session_destroy();
?>
Validate ip address php
<?php
$ip = “173.0.52.150”;
if(preg_match(“/^(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})$/”,$ip)) {
$parts=explode(“.”,$ip);
foreach($parts as $value){
if(intval($value)>255 || intval($value)<0)
echo “Invalid”;
}
echo “Valid IP address”;
}
?>
Search for a string regular expression php
<?php
preg_match( “/c.*?.*?.*?z/”, “phpcodez.com”, $result );
if(count($result))
print_r($result);
?>
preg_match
<?php
preg_match( “/c.*?.*?.*?z/”, “phpcodez.com”, $result );
if(count($result))
print_r($result);
?>