ata
ata

Reputation: 9011

Reading php.ini using zend for PHP extension (not PHP language)

I am trying to read some settings from php.ini using zend. The API that I am using is

long zend_ini_long(char *name, uint name_length, int orig)

But it always returns 0. I have double checked the name and also made sure that the value I am specifying in php.ini is greater then 0. Is there anything I am missing?

Upvotes: 3

Views: 952

Answers (3)

Wez Furlong
Wez Furlong

Reputation: 4987

 long maxwait = zend_ini_long("max_execution_time",
     sizeof("max_execution_time"), 0);

The problem is that ZEND_STRL is not returning the right length for the way that this API is intended to be used, so don't use it.

I should add that most of the hash tables maintained internally by PHP assume that the NUL terminator character is included in the length of the string being hashed (its part of the overall binary safety concept), which is why we use sizeof() rather than strlen() or sizeof()-1.

Upvotes: 3

lo_fye
lo_fye

Reputation: 6840

You can use the standard php function: ini_get('var-name');

Example:

ini_get('include_path');

Upvotes: 0

Johan
Johan

Reputation: 20763

Do you need to read php.ini file? Maybe the information is available with phpinfo()?

But if you must are the "www user" allowed to read the file at all? If you change permissions does it still return 0?

Upvotes: 0

Related Questions