Ask a question that shows a picture
I want to make a PHP page with the Find image function, with id=xx,php in the URL to get the ID value with get. If a picture with the same file name and ID is found, it displays "Load.gif" if it is not found. I am pure novice, referring to the example of the Internet to write a paragraph, but there is no way to display pictures. Please guide the experts.
The code is as follows:
$id =$_get["id"];
$filename = "/' $id '. gif";
if (file_exists ($filename)) {
echo ReadFile ($filename);
}
else {
echo ReadFile ('/load.gif ');
}
?>
------Solution--------------------
$filename = "/' $id '. gif";
Why do you want price quotes?
$filename = "/$id. gif";
------Solution--------------------
References:
I want to make a PHP page with the Find image function, with id=xx,php in the URL to get the ID value with get. If a picture with the same file name and ID is found, it displays "Load.gif" if it is not found. I am pure novice, referring to the example of the Internet to write a paragraph, but there is no way to display pictures. Please guide the experts.
The code is as follows:
$id =$_get["id"];
$filename = "/' $id '. gif";
if (file_exists ($filename)) {
echo ReadFile ($filename);
}
else {
echo ReadFile ('/load.gif ');
}
?>
Wrote a demo to see.
$id = Isset ($_get[' id ')? $_get[' id ']: 0;
$filename = Intval ($id). ". GIF ";
if (file_exists ($filename)) {
Echo ';
}else{
Echo ';
}