Why won't this code work?
问题 Can anyone tell me why this code won't work? <?php $err=1; ?> <img src="334234234234234.gif" onError="<?php $err=0; ?>" /> <?php echo "<br />" . $err; ?> Even when the image exists, the onerror is still executed. Why? 回答1: HTML cannot set PHP variables. Those can only be set while on the server. The onError method of the IMG tag has no access to PHP variables. The page life-cycle: (SERVER) The server builds your page (handling variables, etc) (SERVER -> CLIENT) The server sends out the page