Dev01 Posted March 4, 2009 Share Posted March 4, 2009 Hi all New to PHP ... How would I use a site_url function to call the URL of my website. For example: <?php echo site_url('login.php') ?> Placing the statement above simply results in an error, undefined function. Thanks very much in advance Quote Link to comment https://forums.phpfreaks.com/topic/147947-fetching-the-site-url/ Share on other sites More sharing options...
RussellReal Posted March 4, 2009 Share Posted March 4, 2009 <?php header('Location: login.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/147947-fetching-the-site-url/#findComment-776500 Share on other sites More sharing options...
globalinfoco Posted March 4, 2009 Share Posted March 4, 2009 You didn't define the function. I'm not sure exactly what you're looking for, but if you're just wanting to use php to get the url or the page where the script is executing, look for what you want in the $_SERVER array (google $_SERVER and read the php manual -- it gives good examples). Some will give the complete path, some the domain name only, some the script only...etc. For example: <?php echo $_SERVER['SERVER_NAME']; ?> should give you something like www.example.com therefore... <?php $mysite=$_SERVER['SERVER_NAME']; echo "My website is: $mysite"; ?> should give you something like: My website is: www.example.com header('Location: login.php'); will forcefully redirect your users to the login.php page. If this is what you want to do, be sure to do this before any output and follow it immediately with exit; Quote Link to comment https://forums.phpfreaks.com/topic/147947-fetching-the-site-url/#findComment-776665 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.