Solved

php5: how do i read file from parent directory

Posted on 2011-09-19
2
318 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

770 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