在我的php脚本中,我创建了一个常量变量来定义要放入超链接的基本url,但我真的需要这个吗?
以下是我的意思的示例。
我有这个:
// base url is only defined once and reused throughout
define("__BASE_URL","http://localhost/test1/");
print '<a href="'.__BASE_URL.'index.php?var1=open/>Open</a>';
我有很多这样的内容散布在我的脚本中。
我试过这个方法,它有效:
print '<a href="index.php?var1=open/>Open</a>';
那么这种操作方式的正确方法是什么?我注意到第二种方法甚至适用于加载图片、css和javascript文件。