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
Solved

php5: how do i read file from parent directory

Posted on 2011-09-19
2
319 Views
Last Modified: 2012-05-12
hello all,

i have a zend project with followed structure:

Projectname/application/configs/config.ini

Projectname/public/mytest/test.phtml

in config.ini i have an entry: username = abc

the question is: i would write some codes in test.phtml to check if config.ini exist, if it exist, i would like to get the value of username from this file. any suggestion?

thanks,
wantime
0
Comment
Question by:wantime
2 Comments
 
LVL 13

Accepted Solution

by:
Hugh McCurdy earned 500 total points
ID: 36563814
I assume you are trying to find the file instead of asking about how to do read and write operations in PHP.

Two approaches since it doesn't appear that you are trying to get above the document root.

First is to use a relative path.  Say you are in the folder /Foo/Bar/Bletch and you want to read a file in /Foo/etc called config.ini.  You would open "../../etc/config.ini"

The second works if your server is a *nix operating system and you have shell access.  Simply create a symbolic link from the current folder to the file.

$ ln -s  ../../etc/config.ini  config.ini

.. means the parent folder.
0
 

Author Comment

by:wantime
ID: 36568485
thanks.

actually i also would like to read the file.  the link followed helps.

http://devilsworkshop.org/parsing-ini-files-using-php/
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Syntax Error 4 32
How is this connection happening? 3 20
MVC - procedural PHP 10 34
Accessing specific element - DOM PHP HTML 8 34
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

791 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