Example
<?php
echo acos(.90);
?>
Output
0.45102681179626
Example
<?php
echo acos(.90);
?>
Output
0.45102681179626
Example
<?php
echo $abs = abs(-1.7);
?>
Output
1.7
<?php
$val=2;
if ($val>1)user_error(“A custom error has been triggered”);
?>
Example
<?php
$val=2;
if ($val>1)trigger_error(“A custom error has been triggered”);
?>
Example
<?php
function customException($exception){
echo $exception->getMessage();
}
set_exception_handler(‘customException’);
throw new Exception(‘Uncaught Exception occurred’);
?>
Output
Exception: Uncaught Exception occurred
Example
<?php
function errorFunc($errno, $errstr, $errfile, $errline) {
echo $errstr.” on ” . $errfile .” at “. $errline;
}
set_error_handler(“errorFunc”);
$val=5;
if ($test>1) trigger_error(“An error occured”);
?>
Output
Undefined variable: test on /var/www/test/index.php at 7
Example
<?php
function customError($errno, $errstr, $errfile, $errline) {
echo $errno.””.$errstr.” , File name – “.$errfile.” at line No”.$errline;
}
set_error_handler(“customError”);
$val=5;
if ($val>1) trigger_error(“An error occured”);
restore_error_handler();
if ($val>5) trigger_error(“An error occured”);
?>
Output
exception_handler_1 – This triggers the first exception handler…
Example
<?php
function customError($errno, $errstr, $errfile, $errline) {
echo $errno.””.$errstr.” , File name – “.$errfile.” at line No”.$errline;
}
set_error_handler(“customError”);
$val=5;
if ($val>1) trigger_error(“An error occured”);
restore_error_handler();
if ($val>5) trigger_error(“An error occured”);
?>
Output
1024An error occured , File name – /var/www/test/date/date.php at line No11
Example
<?php
error_reporting(E_ALL);
?>
E_ERROR ,E_WARNING,E_PARSE,E_NOTICE,E_CORE_ERROR,E_CORE_WARNING ,E_COMPILE_ERROR,E_COMPILE_WARNING,E_USER_ERROR,E_USER_WARNING,E_USER_NOTICE,E_STRICT ,E_RECOVERABLE_ERROR,E_ALL
Output
It shows all the errors occurred including waring,notice etc
<?php
$value=2;
if ($value>1){
error_log(“An error occured”,1,”info@phpcodez.com”,”From: from@phpcodez.com”);
}
?>