Jump to content

new install of xampp ... str_pad() expects parameter 4 to be long


dsdsdsdsd

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.