扫码关注官方订阅号
各位大哥。请问下,我是小白同一个网页,我绑定了多个域名,比如我要让www.bd.com访问的话,就是背景图就改成b.jpg。其他的话就默认是之前设置的那个背景图
谢谢老板
<?php $domain = $_SERVER['HTTP_HOST']; if ($domain == 'www.bd.com') { $backgroundImage = 'b.jpg'; } else { $backgroundImage = 'default.jpg'; // 默认背景图 } ?> <!DOCTYPE html> <html> <head> <style> body { background-image: url(<?php echo $backgroundImage; ?>); } </style> </head> <body> <!-- 页面内容 --> </body> </html>
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
谢谢老板
<?php $domain = $_SERVER['HTTP_HOST']; if ($domain == 'www.bd.com') { $backgroundImage = 'b.jpg'; } else { $backgroundImage = 'default.jpg'; // 默认背景图 } ?> <!DOCTYPE html> <html> <head> <style> body { background-image: url(<?php echo $backgroundImage; ?>); } </style> </head> <body> <!-- 页面内容 --> </body> </html>