我正在尝试根据 URL 中的 ID 加载图像:
例如:www.exampleurl.com/API/upload/1.jpg 包含一张图片。
当我访问 www.exampleurl.com/photo/index.php?id=1 时,我试图将该图像加载到单独的 PHP 文件中
到目前为止,我的代码似乎不起作用:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
intval($_GET['id']);
?>
<h1> <center> This is the image: </center> </h1>
<img src="http://exampleurl.com/API/upload/<?php echo $id;?>.jpg" alt="some_text">
</body>
</html>
如有任何帮助,我们将不胜感激。
最佳答案
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
$id = intval($_GET['id']);
?>
<h1> <center> This is the image: </center> </h1>
<img src="http://exampleurl.com/API/upload/<?php echo $id;?>.jpg" alt="some_text">
</body>
</html>
你必须指定 $id
关于php - 基于 URL ID 加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17796499/