You are here: Re: Use file() function to read a variable name, not a literal name. « PHP Programming Language « IT news, forums, messages
Re: Use file() function to read a variable name, not a literal name.

Posted by walterbyrd on 12/17/78 11:54

Alvaro G. Vicario wrote:
> What error are you getting?
>

This is what I'm using. It is copied almost verbatim from the php.net
examples for using the file() function. One difference: I'm using a
variable ($userfile), instead of a literal. The variable does contain a
file name, I've checked. If I replace the variable, with a literal,
this will work.

// Get a file into an array. In this example we'll go through HTTP to
get
// the HTML source of a URL.
$lines = file($userfile);

// Loop through our array, show HTML source as HTML source; and line
numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br
/>\n";
};

Here is the error that I'm getting:

Warning: Invalid argument supplied for foreach() . . .

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация