How to write this correctly?
| From: | Labunski | Date: | Sat, 06 Mar 2004 13:50:04 +0000 |
| Subject: | How to write this correctly? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179643@lists.php.net to get a copy of this message | ||
// or example I have some link:
<a href='index.php?action=people'>About people</a>
// so this function will output the content of people.txt file:
if ($action=="people"){
function output() {
$file = file("data/people.txt");
foreach($file as $value ) {
$output .= "$value<br>";
}
return $output;
}
$content = output();
}else{
error ();
}
// How can I improve this function so, that it will work automaticly with
other links (below) too.
<a href='index.php?action=industry'>Factories</a>
<a href='index.php?action=art'>Beautiful pictures</a>
<a href='index.php?action=animals'>Zoo</a>
<a href='index.php?action=contact'>Contact us</a>
P.S.
I have tried to improve If tag and the name of .txt file this way:
if ($action=="$action"){
function output() {
$file = file("data/".$action.".txt");
.. but the syntax is incorrect.
What to do?
Thanks,
Roman