Solved

read from a consts file in php

Posted on 2013-12-31
10
411 Views
Last Modified: 2014-01-05
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
Comment
Question by:weissman
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 77

Expert Comment

by:arnold
ID: 39748278
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
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39748303
Same operation in PHP:

$host=shell_exec(". /xxx.consts; echo \$JBOSS_HOST");
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39748409
Would be helpful to see the file so we can see how it is going to interact with the PHP script.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:weissman
ID: 39750791
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
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 39751293
Ummm... if you used shell_exec, then why didn't you accept my answer?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39751308
Ummm... if you used shell_exec, then why didn't you accept gr8gonzo's answer?
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 39751322
Echo? :)
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39751331
Echo Echo :)
0
 

Author Comment

by:weissman
ID: 39751470
forgive me :)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question