|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-21 07:39 UTC] momchil dot bozhinov at hp dot com
Description: ------------ I get a warning while trying to parse ini input. problem is that the input comes from a file stored on the web and sometimes it comes back as HTML (proxy issue). The warning is reported as "syntax error", which I understand as something that got out of the variable and was executed. Test script: --------------- <?php $result = "<HTML><HEAD> <TITLE>Network Error</TITLE> </HEAD> <BODY> <FONT face=\"Helvetica\"> <big><strong></strong></big><BR> </FONT> <blockquote> <TABLE border=0 cellPadding=1 width=\"80%\"> <TR><TD> <FONT face=\"Helvetica\"> <big>Network Error (dns_unresolved_hostname)</big> <BR> <BR> </FONT> </TD></TR> <TR><TD> </FONT> </TD></TR> <TR><TD> </BODY></HTML>"; parse_ini_string($result); // ===== 5.4 RC8 // Warning: syntax error, unexpected '=' in Unknown on line 9 // in C:\Users\***\Desktop\SFK\AutoPHP\bug.php on line 25 // ===== 5.3.10 // Warning: syntax error, unexpected '=' in Unknown on line 9 //in C:\Users\bozhinov\Desktop\SFK\AutoPHP\php53\bug.php on line 25 ?> PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 19:00:01 2025 UTC |
Usually a syntax error in an ini file is a pretty serious situation that there is no recovery from. So a big warning tends to be warranted. But, if you really do have a situation where it is ok for there to be syntax errors in your ini, then just swallow the error and check the return. eg. if(!@parse_ini_string($result)) { echo "Fail!"; } else { echo "Ok"; }