PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello, I have a mostly html static website. I have it split into a few section using php includes for ease of updating. I have some scripts that I only want to load on certain pages, how to I tell them to only load for that one page? In header.php for example, how can I say "if pageX.php - do this"
jaoudestudios, thanks for the tip! Do you have an example of this in use somewhere? I am going to need some hand holding on this one. I am not a programmer, always just been a front end guy, so this is new territory for me. An example on how you would actually write it out on the page would help a ton, or a link to examples.
<html>
<head>
<!-- scripts for all pages --->
<script type="text/javascript" src="/js/script1.js"></script>
<script type="text/javascript" src="/js/script2.js"></script>
<?php
if($_SERVER['script_name'] == "home.php") {
?>
----------- Stick whatever content you want to be on home.php here --------------------
<?php
} elseif($_SERVER['script_name'] == "members.php") {
?>
----------- Stick whatever content you want to be on members.php here --------------------
<?php
}
?>
</head>
<body>
</body>
</html>
Last edited by Loki on Fri Jun 19, 2009 9:58 am, edited 1 time in total.
Perfect! That is what I was looking for. I know this is in no way a proper way to build a php page, but for what I am doing it works. I will try this out later today. Thanks for all the advice!