Jump to content


Photo

define a url for include()


  • Please log in to reply
1 reply to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 July 2006 - 04:25 AM

I am wanting to define a url in a seperate file, say constant.php and call that when needed.

Here is an example
<?php
include("../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") 
?>

Here is an example of the constant file

<?php 
$url = "http://www.owpt.biz" 
?>

I know that it would be easier, for now , to just use include("http://www.owpt.biz/...ludes/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.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 July 2006 - 04:27 AM

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 function

function 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 is

include("test.php");

// call the function name and use anywere within the script.

email($email_address);

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users