Fungsi user_error
Fungsi user_error (juga dikenali sebagai trigger_error) menjana mesej ralat pengguna. Parameter pertama menerima rentetan mesej, parameter kedua - jenis ralat (E_USER_NOTICE, E_USER_WARNING atau E_USER_ERROR).
Sintaks
user_error(message, error_type);
Contoh
Jana notis mudah (E_USER_NOTICE):
<?php
user_error('This is a notice', E_USER_NOTICE);
?>
Keputusan pelaksanaan kod:
Notice: This is a notice
Contoh
Jana amaran (E_USER_WARNING):
<?php
user_error('Warning: invalid value', E_USER_WARNING);
?>
Keputusan pelaksanaan kod:
Warning: Warning: invalid value
Contoh
Jana ralat fatal (E_USER_ERROR):
<?php
user_error('Critical error occurred', E_USER_ERROR);
echo 'This line will not execute';
?>
Keputusan pelaksanaan kod:
Fatal error: Critical error occurred