Pelajaran Syntax PHP set_exception_handler & Error_log

Pelajaran Syntax PHP set_exception_handler & Error_log
BAB set_exception_handler()

Berfungsi untuk exception selama program berjalan
Syntax Dasar;
set_exception_handler(exception_function)
Contohnya:
<?php
function myException($exception)
{
echo "<b>Exception:</b>" , $exception-> getMessage();
}
set_exception_handler('myException');
throw new Exception('Uncaught Exception occurred');
?>
 BAB error_log()

Befungsi untuk mengirimkan catatan kesalahan (error) ke server atau tujuan lainnya., Syntax dasar;
error_log(error,type,destination,headers)

Contohnya:
<?php
$test=2;
if ($test>1) { error_log("error log",1,"asiankonsultasionline@yahoo.com",from:sutimahprogrammer@gmail.com"); }
?>
BAB filter_var()

Berfungsi untuk memfilter variable dengan spesifikasi filter tertentu.
Syntax Dasar
filter_var(variable,filter,option)
Contohnya;
<?php
if(!filter_var("asiankonsultasionline@yahoo.com",FILTER_VALIDATE_EMAIL)) {echo ("alamat e-mail tidak valid"); }
}
else { echo("Alamat e-mail Valid"); }
?>

BAB filter_input()

Berfungsi sebagai validasu variable yang bersumber dari beberapa sumber, seperti unsur input, cookie dan session.
Syntax Dasar;
filter_input(input,variable,filter,option)
Contohnya;
<?php
if (!filter_input(INPUT_POST, 'email',FILTER_VALIDATE_EMAIL))
{
echo ("Alamat e-mail tidak valid");
}
else
{
echo ("Alamat e-mail Valid");
}
?>
 ===================================================================


Komentar