LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2006, 10:02 PM   #1
enigma_0Z
Member
 
Registered: Apr 2005
Distribution: Ubuntu, RHEL, Darwin
Posts: 73

Rep: Reputation: 15
Problems with PHP file functions... (many problems)


Here's my code:

Code:
<html>
        <head>
                <title>Dir Test</title>
        </head>
        <body>
                <p>
                        <?
                        $dir    = 'test';
                        $pages = scandir($dir, 1);
                        ?>

                        <table>

                        <!-- Headers -->
                        <tr><td><b>Name</b></td><td><b>Type</b></td><td><b>Link</b></td><td><b>is_file</b></td></tr>

                        <?
                        for ($i = 0; $i <= sizeof($pages)-3; $i++)
                        {
                                $name = substr($pages[$i], 0, strrpos($pages[$i], "."));
                                $type = substr($pages[$i], strrpos($pages[$i], ".")+1);
                                $link = "<a href=/php/view-text.php?section=".$_GET['section']."&page=".$name.">".$name."</a>";
                                $type = var_dump(is_file($pages[$i]));
                                echo    "<tr><td>".$name."</td>".
                                        "<td>".$type."</td>".
                                        "<td>".$link."</td>".
                                        "<td>".$type;?></td></tr><?
                        }
                        ?>

                        </table>
                </p>
        </body>
</html>
My problem is that no matter what I do:

1. The is_file always returns false, even though I know that those are files, and that they exist. Even though the scandir thinks they are!!

2. When I print the result from var_dump(is_file()), it prints outside of the table (above it in a end-to-end list, as a matter of fact), no matter if I do an "echo $type.</td></tr>" or have it outside the php "echo $type;?></td></tr><?". If I remove the </td></tr> stuff, then I get them inside the table, but they're shifted up one cell....

I'm probably just missing something silly though...
 
Old 04-22-2006, 07:15 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Since the files are in the directory test, you probably need to tell php to look in that directory before doing the is_file test, try:

$type = var_dump(is_file($dir."/".$pages[$i]));
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: huge functions file vs multiple small files carlosruiz Programming 2 06-14-2005 03:06 AM
gSOAP problems with nested functions Mq2004 Programming 0 03-27-2005 04:26 AM
Problems using PHP's IMAP functions... LWillmann Red Hat 4 04-11-2004 01:55 PM
Using wildcards with PHP file functions patpawlowski Programming 3 03-18-2004 09:20 AM
can't use some functions in php - freetype problems? andrew001 Linux - Software 0 06-25-2003 11:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration