1

Does anyone know how to use a custom $config file? I know ZF and other frameworks such as CakePHP use a custom application.ini file to define application constant variables, environments etc. but how to add a such file and access it's values inside an application built with pure PHP no frameworks.

2 Answers 2

5

Like for almost anything, there already is a function in PHP to do that: parse_ini_file()

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for you answer, it helped me to solve my problem, but what I would also like to do is to use a custom php.ini file or create a custom one in order to override some values from php.ini. I know I could use ini_set(), but I want to change the PHP session name so I will not have to set ini_set(session.name) on each page where I use session_start().
4

You can access the contents of custom ini files with the parse_ini_file() function. It will return an associative array representing the settings specified in the file.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.