I am confused and couldn’t figure out the difference between these two lines!!
echo "<li><a href='category-".$row['id'].".php' >".$row['name']."</a></li>";
The first one echos categories I displayed in a home page. It works fine and I don’t have to create the category.php file.
echo "<li><a href='category-.php".$row['id']."' >".$row['name']."</a></li>";
But the second code it tells me file doesn’t exist.
So my question is, why the first code doesn’t require the file but the second code does?
It makes sense why the second file doesn’t exist – look at the filename you’re constructing:
Unless you have a file called
category-with an extension that matches\.php\d+, this doesn’t make any sense.The first line makes perfect sense:
This would result in filenames like
category-1.php, orcategory-2.php.