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
phpuser_error(message, error_type);
Contoh
Jana notis mudah (E_USER_NOTICE):
php<?php
user_error('This is a notice', E_USER_NOTICE);
?>
Keputusan pelaksanaan kod:
phpNotice: This is a notice
Contoh
Jana amaran (E_USER_WARNING):
php<?php
user_error('Warning: invalid value', E_USER_WARNING);
?>
Keputusan pelaksanaan kod:
phpWarning: Warning: invalid value
Contoh
Jana ralat fatal (E_USER_ERROR):
php<?php
user_error('Critical error occurred', E_USER_ERROR);
echo 'This line will not execute';
?>
Keputusan pelaksanaan kod:
phpFatal error: Critical error occurred