Z zebono2 Active Member 31 2010 0 10 Jan 7, 2012 #1 im trying to call for a variable for part of a link include ('$themedir; /index.php'); this is not working the variable is $themedir = '/theme/default'; and is located in a diffent .php that had been included before
im trying to call for a variable for part of a link include ('$themedir; /index.php'); this is not working the variable is $themedir = '/theme/default'; and is located in a diffent .php that had been included before
H hugo04 Active Member 226 2009 0 0 Jan 7, 2012 #2 1. can't call variable inside include 2. for your work, I suggest you do if (index){ $themedir = '/theme/default'; }else{ $themedir = ' '/theme/default2'; } load $themedir hope this will help you guy
1. can't call variable inside include 2. for your work, I suggest you do if (index){ $themedir = '/theme/default'; }else{ $themedir = ' '/theme/default2'; } load $themedir hope this will help you guy
S soft2050 Active Member 2,942 2010 438 0 Jan 7, 2012 #3 hugo04 said: 1. can't call variable inside include Click to expand... Wrong, you can use variables inside a include statement ---------------------------- PHP: include ('$themedir; /index.php'); Why is there a ; in the code and to use variables you need to use double quotes (") PHP: include ("$themedir/index.php"); Also, the themedir variable: PHP: $themedir = '/theme/default'; Whats the path from the script you are using? use realpath() to check whether you are on the right directory or not http://php.net/manual/en/function.realpath.php
hugo04 said: 1. can't call variable inside include Click to expand... Wrong, you can use variables inside a include statement ---------------------------- PHP: include ('$themedir; /index.php'); Why is there a ; in the code and to use variables you need to use double quotes (") PHP: include ("$themedir/index.php"); Also, the themedir variable: PHP: $themedir = '/theme/default'; Whats the path from the script you are using? use realpath() to check whether you are on the right directory or not http://php.net/manual/en/function.realpath.php
J jokerhacker Active Member 415 2010 45 0 Jan 7, 2012 #4 soft2050 is right. just another note, if you get problems about the path, use PHP: include (getcwd() . "/$themedir/index.php");
soft2050 is right. just another note, if you get problems about the path, use PHP: include (getcwd() . "/$themedir/index.php");
Z zebono2 Active Member 31 2010 0 10 Jan 7, 2012 #5 thanks guys i got it working by using include ("$themedir/index.php");
R Robin H Active Member 807 2009 73 0 Jan 8, 2012 #6 I'm actually not a big fan of double quotes. Personally I tend to always use single quotes when possible. Here you have both methods: PHP: <?php include($themedir . '/index.php'); // Notice the dot ?> <?php include("$themedir/index.php"); ?>
I'm actually not a big fan of double quotes. Personally I tend to always use single quotes when possible. Here you have both methods: PHP: <?php include($themedir . '/index.php'); // Notice the dot ?> <?php include("$themedir/index.php"); ?>