Solved

read from a consts file in php

Posted on 2013-12-31
10
405 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 76

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 108

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
 

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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 34

Expert Comment

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

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 108

Expert Comment

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

Author Comment

by:weissman
ID: 39751470
forgive me :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now