Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

read from a consts file in php

Posted on 2013-12-31
10
Medium Priority
?
444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 79

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

730 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