• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 456
  • Last Modified:

read from a consts file in php

i have a file that include constants that is used as Enivroment parameters.

in perl i can get the value of a specific variable like this:

$host=`. /xxx.consts; echo \$JBOSS_HOST`;

how to perform the same opration in PHP

note: i couldn't use parse_ini_file() because i canot change the xxx.consts file to ini  

thanks a lot
0
weissman
Asked:
weissman
  • 3
  • 3
  • 2
  • +1
1 Solution
 
arnoldCommented:
if those are variable assignments, you can require/include the file that will preload the constants.
http://www.w3schools.com/PHP/php_includes.asp
perl would also use a use/require to preload variable assignments.

What are the contents of the file?

is the xxxxx.constant file something like:
#!/usr/bin/perl
$JBOSS_HOST="somehostname";
1;

Open in new window

0
 
gr8gonzoConsultantCommented:
Same operation in PHP:

$host=shell_exec(". /xxx.consts; echo \$JBOSS_HOST");
0
 
Ray PaseurCommented:
Would be helpful to see the file so we can see how it is going to interact with the PHP script.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
weissmanAuthor Commented:
i have use the echo shell_exec() in the end

note: the consts was calling the shell so i call it directly from php

thanks a lot
0
 
gr8gonzoConsultantCommented:
Ummm... if you used shell_exec, then why didn't you accept my answer?
0
 
Ray PaseurCommented:
Ummm... if you used shell_exec, then why didn't you accept gr8gonzo's answer?
0
 
gr8gonzoConsultantCommented:
Echo? :)
0
 
Ray PaseurCommented:
Echo Echo :)
0
 
weissmanAuthor Commented:
forgive me :)
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now