0

I've been getting along ok-ish in pset 8 but one thing I have been trying to figure out for a few days and am still not getting correct. The function file_exist() should return false when a file doesn't exist but for one reason or another this if condition does run.

// check if file exists
$file = $argv[1];

if (file_exists($file) == FALSE)
{
    exit("[ERROR] ".$file." not found\n");
}


// rest of code

The tree output for my ~/vhosts/pset8 directory is:

./pset8/
|-- bin
|   |-- US.txt
|   `-- import


The command I run is:

(~/vhosts/pset8/bin): php import pset8/US.txt

Anyone an idea what I'm doing wrong (I have the feeling something extremely simple... but then again, I've been looking at it for a while now)

0

your US.txt seems to be located under pset8/bin/. you're passing pset8/US.txt as a command-line argument to import. this makes file_exists look under pset8/bin/pset8 which actually doesn't exist. I'll leave it to you to figure out how you can fix this.

1
  • sometimes you see the answer and you just feel stupid for asking... ;) thanks!
    – Vincent
    Jan 26 '16 at 23:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .