Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

read from a consts file in php

Posted on 2013-12-31
10
Medium Priority
?
452 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 80

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 35

Accepted Solution

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

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

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 35

Expert Comment

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

Expert Comment

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

Expert Comment

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

Expert Comment

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

Author Comment

by:weissman
ID: 39751470
forgive me :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

926 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