Extract (ever) correct domain name for cookie – php function

This function extract and return, the correct domain name for any passed value.

Get ever the correct cookie domain name, iterating into array only one time:

switch if on localhost:

(on WP_w3all plugin phpBB/WP)

Get complete Domains Names list updated at runtime (array)

The more convenient code that i’ve find out in mind, to get in any case, the correct cookie domain name, where many other different ways fails.
I do not think: but asking myself if there is possibility to have the same result, in less code and more fast than this.

All Domains Names updated at runtime (array)

Prevent Warning: POST Content-Length of bytes exceeds the limit – how to fix smartly

When a form multipart/form-data is submitted to send a file, if dimension of submitted file on form to be uploaded, exceeds the dimension of MAX_FILE_SIZE value,  PHP emit a warning and the $_FILES global is empty.

Warning: POST Content-Length of …. bytes exceeds the limit

In WordPress you have something like:

Warning: POST Content-Length of ….. bytes exceeds the limit of … bytes in Unknown on line 0

To resolve the problem about if dimension of submitted file to upload exceeds the dimension of MAX_FILE_SIZE value (Php emit a Warning)  server side, there is no pre javascript check needed, no ini_set value to change (if not needed), the php warning (as anything else you do not want emitted by the browser before you do not want really it) can be removed from output with the follow Php code, that need to be placed at the very start of the Php file you call (that will receive the empty $_FILES input and that so will emit the Php warning).

The code is just this:

That is.  After …

manage what to do. You could also use Javascript to detect and process the file. Maybe chunk it and enqueue for the upload.

This i had use to resolve an old bug in WP about RSS, that was not well parsed by browsers as the output was containing spaces before the code to be interpreted. The solution was +- the same:

Answered How to prevent Warning: POST Content-Length at: stackoverflow.com