Solution to the Notice: Undefinedindex error prompt in php
- If (array_key_exists ('strue ', $ _ POST ))
- {
- If ($ _ POST ['strue'])
- {
- $ Istrue = $ _ POST ['strue'];
- }
- } Else {
- $ Istrue = '';
- }
The following judgment can be made:
- Elseif ($ istrue = 'OK ')
To avoid such errors, you can refer to some program systems. For details, refer to dedecms or phpcms code.
// Check and register external submitted variables
- Foreach ($ _ REQUEST as $ _ k => $ _ v)
- {
- If (strlen ($ _ k)> 0 & eregi ('^ (cfg _ | GLOBALS)', $ _ k ))
- {
- Exit ('request var not allow! ');
- }
- }
- Function _ RunMagicQuotes (& $ svar)
- {
- If (! Get_magic_quotes_gpc ())
- {
- If (is_array ($ svar ))
- {
- Foreach ($ svar as $ _ k = >$ _ v) $ svar [$ _ k] = _ RunMagicQuotes ($ _ v );
- }
- Else
- {
- $ Svar = addslashes ($ svar );
- }
- }
- Return $ svar;
- }
Foreach (Array ('_ get',' _ post', '_ COOKIE') as $ _ request)
- {
- Foreach ($ _ request as $ _ k = >$ _ v) $ {$ _ k} = _ RunMagicQuotes ($ _ v );
- }
- If (empty ($ istrue ))
- {
- $ Istrue = '';
- }
|