Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

PHP Get Date Example

<?php
   $date_array = getdate();
   
   foreach ( $date_array as $key => $val ){
      print "$key = $val<br />";
   }
	
   $formated_date  = "Today's date: ";
   $formated_date .= $date_array['mday'] . "/";
   $formated_date .= $date_array['mon'] . "/";
   $formated_date .= $date_array['year'];
   
   print $formated_date;
?>

PHP Date and Time

<?php
   print time();
?>

PHP Function user_error()

<?php
    if ($test<10) {
    user_error("Number cannot be less than 10");
}
?> 

PHP Function trigger_error()

<?php
 if ($test<10) {
    trigger_error("Number cannot be less than 10");
}
?> 

PHP Function set_exception_handler()

<?php
   function exception_handler($exception) {
      echo "Uncaught exception is : " , $exception->getMessage(), "\n";
   }
   
   set_exception_handler('exception_handler');
   set_exception_handler();
   
   throw new Exception('Not Found Exception');
   echo "not included Executed\n";
?> 

PHP Error Handler Function Example

<?php
   function customError($errno, $errstr, $errfile, $errline) {
      echo "Custom error: [$errno] $errstr\n";
      echo "Error on line $errline in $errfile\n";
      echo "Ending Script";
      
      die();
   }
   
   //set error handler
   set_error_handler("customError");
   $test = 0;
   
   //trigger error
   if ($test >  -1) {
      trigger_error("A custom error has been triggered");
   }
?> 

PHP Function restore_error_handler()

<?php
   function unserialize_handler($errno, $errstr) {
      echo "Invalid hello value.\n";
   }
   
   $hello = 'abc';
   set_error_handler('unserialize_handler');
   
   $original = unserialize($hello);
   restore_error_handler();
?> 

Function error_get_last()

<?php
   echo $b;
   print_r(error_get_last());
?> 

PHP Function debug_print_backtrace()

<?php
   function one() {
      two();
   }
   
   function two() {
      three();
   }
   
   function three(){
      debug_print_backtrace();
   }
   one();
?> 

PHP Function debug_backtrace()

<?php
   function printStr($str) {
      echo "Hi: $str";
      var_dump(debug_backtrace());
   }
   
   printStr('hello');
?> 

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.