dsdsdsdsd Posted February 11, 2011 Share Posted February 11, 2011 hello; I installed xampp today ( v2.5 ) and all of my old php/mysql stuff is haywire. ONE example is this: $lvs_result = str_pad( 1 , 4 , "0" , "STR_PAD_LEFT" ) ; print ( $lvs_result . "\n" ) ; //==> Warning: str_pad() expects parameter 4 to be long, string given in C:\xampp\htdocs\testing\index.php on line 18 I am getting dozens of warnings for all kinds of functions however .. any thoughts? old php was 5.2 ... new php is 5.3. thanks. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 11, 2011 Share Posted February 11, 2011 STR_PAD_LEFT is a constant. if you put quotes around it, it becomes something different. remove the quotes // FIXED $lvs_result = str_pad( 1 , 4 , 0 , STR_PAD_LEFT); Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 11, 2011 Share Posted February 11, 2011 After you fix what is causing each warning/notice/error, the issue in most of these cases is simply that your error_reporting/display_errors settings where hiding all the warnings/notices/errors. Your code was always producing the warnings/notices/errors but you did not see them. For the specific example you posted, your code wasn't producing the intended result the way you had it (with the quotes), so it is likely that a lot of your code will start doing what you expect after you fix what is causing each warning/notice/error. Quote Link to comment Share on other sites More sharing options...
dsdsdsdsd Posted February 11, 2011 Author Share Posted February 11, 2011 O this is ugly ... ignorance WAS bliss ... I have a hard time believing that I ever would have turned off 'warning's ... maybe it was turned off by default in PHP5.2.# when I installed it 3 years ago ( yeah I have 3 years worth of warnings to clean up ). Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 12, 2011 Share Posted February 12, 2011 Unfortunately, php.net itself took the position that completely suppressing some types of errors and hiding error messages in general was an acceptable programming method, even when learning and during development (it is only in php5.3 that the php.ini suggests settings specifically for development), and the makers of the all-in-one development systems (they are not intended for any other purpose) blissfully and unknowingly followed along and distributed systems that hindered the efficient creation of php code during development and for those trying to learn the language. We have seen countless posts on the forum where the error messages, had all of them been reported and displayed, would have saved a TON of time by pointing out things like typos, missing parameters and values, wrong information/usage in the code, and other basic problems that everyone makes while learning a programming language and while writing code. In just about every one of the 'my code is not working and there are no errors being shown' posts, the first reply is a suggestion to set the error_reporting and display_errors settings to get ALL the php detected errors to be reported and displayed so that there is SOME information upon which to narrow down and find what is causing the problem. Php scripts should not produce any php detected errors of any kind during their normal execution. Scripts should only produce php errors for unexpected things, which should be logged on a live server, like a legitimate visitor entering an unexpected value that your validation logic did not deal with, the hacker feeding your code all kinds of unexpected data in an attempt to break into the script, the mail/database server that sometimes does not work or that got reconfigured and is preventing your script from using it, the remote server you are trying to access that is not working, ... You do want a record of errors caused by these type of things, but these are the only errors you should see in your error log, not 100's of thousands of warning/notice messages because your script produces a couple of dozen errors every time it runs. P.S. Scripts run a tiny bit faster and use less server resources if they don't regularly produce errors that have to be handled by the php language engine (even if you don't report, log, or display the errors, php must still deal with each one them every time they occur) and writing lines to the error log file adds processing and disk overhead every time php does it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.