在服务器上处理本地php文件,无需指定直接ip或域名

在服务器上处理本地php文件,无需指定直接ip或域名,php,Php,我有以下php文件,用于获取和显示数据库中读取的图像 <?php require_once('database.php'); $db = new Database(); $id = $_GET['id']; $order = $_GET['order']; // do some validation here to ensure id is safe header('Content-type: image/jpeg'); echo pg_unescape_bytea($db-&g

我有以下php文件,用于获取和显示数据库中读取的图像

<?php

require_once('database.php');
$db = new Database();

$id = $_GET['id'];
$order = $_GET['order'];


// do some validation here to ensure id is safe

header('Content-type: image/jpeg');
echo pg_unescape_bytea($db->getImageById($id, $order));
?>
我试图找到一种方法,不再需要提供硬编码信息,如
example.com
,我希望能够将所有文件移动到另一台服务器和/或域名,而无需更改服务器ip。这是一个脚本,将由多个域名使用


如何做到这一点?

使用
$\u服务器[“HTTP\u主机”]
而不是域名。

我不明白你说的是什么
$img_binary = file_get_contents('http://example.com/helper/getImageById.php?id=' . $id . '&order=1', false);
$img_base64 = base64_encode($img_binary);