tomfmason Posted July 1, 2006 Share Posted July 1, 2006 I am wanting to define a url in a seperate file, say constant.php and call that when needed.Here is an example[code]<?phpinclude("../includes/constant.php");?><?php$filename = "('$url')/products/index.php"; //I am not sure if this is the right way$title = "Products"; // or not?><?php include("$url/includes/construct.php"); //or maybe this would be better?include("$url/includes/main.php") ?>[/code]Here is an example of the constant file[code]<?php $url = "http://www.owpt.biz" ?>[/code]I know that it would be easier, for now , to just use include("http://www.owpt.biz/includes/main.php")but I am going to be using this on more then one site and I don't want to have to go back and update all of the files. Link to comment https://forums.phpfreaks.com/topic/13357-define-a-url-for-include/ Share on other sites More sharing options...
redarrow Posted July 1, 2006 Share Posted July 1, 2006 Put the url in a function then include that file, then call the function to that file.example://please not that php dosent like to use include(""); x amount times,so use the function page to add all common codes and return the funtion to the page.test.php<?php//make a functionfunction email($email_address) {// varable name to the url$email_address="www.phpfreaks.com";echo $email_address;}?>test_result.php<?php // include the page where the function isinclude("test.php");// call the function name and use anywere within the script.email($email_address);?> Link to comment https://forums.phpfreaks.com/topic/13357-define-a-url-for-include/#findComment-51515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.