Jump to content


Photo

Using Variables in PHP.ini?

php variables

Best Answer random1, 14 January 2015 - 06:37 AM

Thanks for the reply.

 

I got it working by creating a .CMD file for creating the Windows Environment Variables (only Windows 7 or later):

SETX DEV_SERVER_DIR D:\webserver /M
SETX DEV_SERVER_APACHE_DIR D:\webserver\apache /M
SETX DEV_SERVER_PHP_DIR D:\webserver\apache /M
SETX DEV_SERVER_MYSQL_DIR "D:\webserver\mysql\MySQL Server 5.6" /M
SETX DEV_SERVER_MYSQL_DATA_DIR "D:\webserver\mysql\MySQL Server 5.6\data" /M
pause

and then in PHP.ini, for example:

[PHP]
include_path = ".;${DEV_SERVER_APACHE_DIR}\htdocs"

and start the Apache Windows Service and check the variable with phpinfo. :D thanks!

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 random1

random1
  • Members
  • PipPipPip
  • Advanced Member
  • 425 posts

Posted 13 January 2015 - 06:54 AM

I'm running the latest stable version of PHP in Apache Server on Windows 7 64-bit.

 

It working fine and set up correctly.

 

I'd like to use ENVIRONMENT VARIABLES or a variable like "%current_directory%" or "..\%current_directory%" in the configuration files for PHP, php.ini.

 

Is this possible? Is php.ini a parsed file, can variables be define and used in it? Help would be much appreciated  :D



#2 Ch0cu3r

Ch0cu3r
  • Moderators
  • Advanced Member
  • 3,418 posts

Posted 13 January 2015 - 01:57 PM

According to the PHP documentation here you can use Windows Environment Variables within the php.ini



#3 random1

random1
  • Members
  • PipPipPip
  • Advanced Member
  • 425 posts

Posted 14 January 2015 - 06:37 AM   Best Answer

Thanks for the reply.

 

I got it working by creating a .CMD file for creating the Windows Environment Variables (only Windows 7 or later):

SETX DEV_SERVER_DIR D:\webserver /M
SETX DEV_SERVER_APACHE_DIR D:\webserver\apache /M
SETX DEV_SERVER_PHP_DIR D:\webserver\apache /M
SETX DEV_SERVER_MYSQL_DIR "D:\webserver\mysql\MySQL Server 5.6" /M
SETX DEV_SERVER_MYSQL_DATA_DIR "D:\webserver\mysql\MySQL Server 5.6\data" /M
pause

and then in PHP.ini, for example:

[PHP]
include_path = ".;${DEV_SERVER_APACHE_DIR}\htdocs"

and start the Apache Windows Service and check the variable with phpinfo. :D thanks!


Edited by random1, 14 January 2015 - 06:44 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users