Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory listing, without the "./" and "../"

Status
Not open for further replies.

Dissonance

Technical User
Dec 19, 2004
4
US
Anyways, so I want to display a directory listing, but I don't want/need the data about the parent folders. It's for a simple link script, so I can throw a bunch of stuff in a folder, and have my web page automatically link it. (I don't like the one build in to apache) Anyways, it's giving me an error, and I can't figure out why.

Code:
<?php
	$folder = './'; //define which dir you want to read
	$dir = opendir($folder); //open directory
			while ($f = readdir($dir)) { //read one file name
				if ($f = "../") {
								echo "<br>";
				} elseif ($f = "./") {
				     			 echo "<br>";
			    } else {
                          		echo "<center><a href=\"$f\">$f</a><br>\n";
			   	}
?>

It's throwing this error to me, and I don't get it, it doesn't make any sense at all.
Code:
Parse error: parse error, unexpected $ in /home/kyminitr/public_html/gallery/config.php on line 12
 
I fixed it. Simply put, I was not using the correct operator.

Changing the = to == (in lines 5 and 7) fixed the issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top