Asked  7 Months ago    Answers:  5   Viewed   23 times

I'm using PHP 5.3.0 and have encountered something that might be a bug (in which case I'll report it) or might be me - so I'm asking to make sure.

When running this code:

ini_set('upload_max_filesize', '10M');
echo ini_get('upload_max_filesize'), ", " , ini_get('post_max_size')

I end up with:

2M, 8M

This is despite my php.ini setting these higher:

upload_max_filesize = 10M
post_max_size = 10M

(occuring only once)

Because the error occurs after setting the value as well as it being set in php.ini I'm inclined to think it's a bug. Can anyone confirm or point me where I'm going wrong?

Update: Looks like restarting Apache fixed this - I always thought it didn't need to be restarted if you changed php.ini.



You can't use shorthand notation to set configuration values outside of PHP.ini. I assume it's falling back to 2MB as the compiled default when confronted with a bad value.

On the other hand, I don't think upload_max_filesize could be set using ini_set(). The "official" list states that it is PHP_INI_PERDIR .

Wednesday, March 31, 2021
answered 7 Months ago

This is more than likely an issue with the size of the file and/or a permission issue between the Apache user and the directory specified. For instance make sure the Apache instance is not running under user (nobody).

Comment to chaos: He is right the tilde (~) can cause issues, but would probably not cause a timeout; it would display a warning. Even if it does work on your system it would probably deposit the file into an unexpected directory or run into some issues if the Apache user (ie www) does not have a valid home directory set.

Wednesday, March 31, 2021
answered 7 Months ago

You can use date_default_timezone_set and all the date/time functions in the script will use it.

Friday, May 28, 2021
answered 5 Months ago

Apparently in my DbConnect class my PHPDoc comments stated that I was returning 'database' when in fact I was returning a 'mysqli' datatype. This was what was causing the error. The simply fix to this problem was to change be PHPDoc annotation to 'mysqli' and the code completions started to work again.

Saturday, May 29, 2021
answered 5 Months ago

You can use the uniqid() function to generate a unique ID

 * Generate a unique ID
 * @link
 * @param prefix string[optional] <p>
 * Can be useful, for instance, if you generate identifiers
 * simultaneously on several hosts that might happen to generate the
 * identifier at the same microsecond.
 * </p>
 * <p>
 * With an empty prefix, the returned string will
 * be 13 characters long. If more_entropy is
 * true, it will be 23 characters.
 * </p>
 * @param more_entropy bool[optional] <p>
 * If set to true, uniqid will add additional
 * entropy (using the combined linear congruential generator) at the end
 * of the return value, which should make the results more unique.
 * </p>
 * @return string the unique identifier, as a string.
function uniqid ($prefix = null, $more_entropy = null) {}
Friday, July 30, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :