Forum Moderators: coopster
I was doing includes this way
<? @include ("http://www.mywebsite.com/advertising/mypage.php");?>
I worked out if I change it to relative it works much much better
<? @include ("../../../../advertising/mypage.php");?>
The question is I can’t seem change it if the php has a parameter for example this script
<?
@include("http://www.mywebsite.com/ advertising/mynewpage.php?p_pc_title=$var_title");
?>
If I change the path to be relative it doesn’t work, it doesn’t run and it doesn’t produce an error.
Can you change it to relative path if you are passing parameters?
Is there any other performance things I can do to speed up my pages?
Thank you
The proper way is to use DOCUMENT_ROOT, so now I do this
$MYROOT=$_SERVER['DOCUMENT_ROOT']
<?php @include($MYROOT . "/advertising/mypage.php");?>
This works great, but still doesn't work if I have paramters
I tried this, but it doesn't work
$MYROOT=$_SERVER['DOCUMENT_ROOT']
<?php @include($MYROOT . "/mynewpage.php?p_pc_title=$var_title");?>
It looks like it would make sense to declare the GET variable before you include it, and then within the included file check for a GET variable, if one doesn't exist, then check for another declared variable. Something like this:
$p_pc_title = $var_title;
include($MYROOT."/mynewpage.php");
Then in mynewpage.php you can test for both variables:
if(isset($_GET['p_pc_title'])) {
$var = $_GET['p_pc_title'];
}
else if(isset($p_pc_title)) { //this should become true with above example
$var = $p_pc_title;
}
I hope this makes some sense. :)
Good luck!
include("/advertising/mynewpage.php?p_pc_title=$var_title");and
include("http://www.mywebsite.com/advertising/mynewpage.php?p_pc_title=$var_title");
In the first syntax php access the local filesystem. This is why you can't pass arguments. Since it's not a http query but a file access, the filename is "mynewpage.php", not "mynewpage.php?p_pc_title=$var_title"
The second syntax forces php to use what it calls a "URL wrapper" (which is usually not enabled on most rented servers). PHP uses a http connection to get a copy of the code. In this case you have several potential problems.
What you really want is syntax #1. If you need to pass arguments maybe you should use an initializing function after including the script.
include("/advertising/mynewpage.php");
newpageInit($var_title);
or set a variable before including;
$p_pc_title=$var_title;
include("/advertising/mynewpage.php");