这是我用于浏览器游戏的一段代码。措辞略有改变,但代码本身运行良好。任何 php 代码都可以放在“if”语句中,我使用了“print”。
///---Various Navigation & Functions Depending on Current Page---///
$findpage = strrpos($_SERVER['PHP_SELF'],'/');
$currentpage = substr($_SERVER['PHP_SELF'],$findpage);
if ($currentpage == '/home.php'){
print "This message is displayed when the client is on the 'home' page.";
print "If you so chose, you can put the entire 'home' page code in here.";
print "While keeping this the only code being executed.";}
if ($currentpage == '/features.php'){
print "This message is displayed when the client is on the 'features' page.";
print "If you so chose, you can put the entire 'features' page code in here.";
print "While keeping this the only code being executed.";}
if ($currentpage == '/menu.php'){
print "This message is displayed when the client is on the 'menu' page.";
print "If you so chose, you can put the entire 'menu' page code in here.";
print "While keeping this the only code being executed.";}
if ($currentpage == '/store.php'){
print "This message is displayed when the client is on the 'store' page.";
print "If you so choose, you can put the entire 'store' page code in here.";
print "While keeping this the only code being executed.";}