PHP verification code @ symbol PHPcode & lt ;? Phpsession_start (); for ($ i0; $ I & lt; 4; $ I ++) {@ $ rand. dechex (rand (160); [email & #; protected], the image cannot be displayed .} @ $ _ SESSION [check_p help PHP verification code @ symbol
PHP code
PHP code
[Email protected]? Incorrect prompt
Notice: Use of undefined constant code-assumed 'code' in F: \ wamp \ apps \ project \ code_sub.php on line 3
Notice: Use of undefined constant code-assumed 'code' in F: \ wamp \ apps \ project \ code_sub.php on line 4
Notice: Use of undefined constant check_pic-assumed 'check _ pic 'in F: \ wamp \ apps \ project \ code_sub.php on line 4
[Email protected] What is the error?
------ Solution --------------------
Quote $ _ SESSION ["check_pic"]
Undefined constant refers to an undefined constant, which is treated as a constant without quotation marks.
------ Solution --------------------
PHP code
For ($ I = 0; $ I <4; $ I ++) {$ rand = ''; $ rand. = dechex (rand (); [email protected], the image cannot be displayed. } $ _ SESSION ['Check _ pic '] = $ rand; [email protected] and all are garbled characters.
------ Solution --------------------
$ Rand. =
This variable is used when no value is assigned, so the notice error occurs. The image is binary and the notice is text. The combination of the two causes the image to fail to be displayed.
Solution:
Assign a value to $ rand first.
$ Rand = '';
------ Solution --------------------
PHP code
Session_start (); $ rand = ''; for ($ I = 0; $ I <4; $ I ++) {$ rand. = dechex (rand (); [email protected], the image cannot be displayed. } $ _ SESSION ['Check _ pic '] = $ rand; [email protected] and all are garbled characters. $ Im = imagecreatetruecolor (255,255,255, 30); $ bg = imagecolorallocate ($ im, 0); $ te = imagecolorallocate ($ im,); imagestring ($ im, 0, $ rand, $ te); header ("content-type: image/jpeg"); imagejpeg ($ im );
------ Solution --------------------
Discussion
PHP code
Session_start ();
For ($ I = 0; $ I <4; $ I ++ ){
@ $ Rand. = dechex (rand (); [email protected], the image cannot be displayed.
}
@ $ _ SESSION [check_pic] = $ rand; [email protected] and all are garbled characters. ......