0

I'm trying to add a name into a defined filepath like this -

define("theme_name", "andrew");
define("LAYOUT_DIR", ROOT_DIR.'_content/layouts/themes/<?php echo $theme_name;?>/');

I get an error that the path does not exist when it is executed but the "andrew" folder does exist.

I tried joining with dots instead of echo and still got this error.

Full error message

Fatal error: Uncaught exception 'Twig_Error_Loader' with message 'The "G:\Uwamp\www\lightbulb_edison/../_content/layouts/themes/ . $theme_name . /" directory does not exist.' ````

3
  • echo is not meant for joining variables. And <?php is pointless within a string or expression. And your theme_name is a constant too, not a variable. Commented Feb 2, 2016 at 4:13
  • Add the whole error message to the question please. Commented Feb 2, 2016 at 4:13
  • stackoverflow.com/questions/2786279/… Commented Feb 2, 2016 at 4:16

2 Answers 2

3

You can use (.) for concatenation in php . like below..

define("theme_name", "andrew");
define("LAYOUT_DIR", ROOT_DIR.'_content/layouts/themes/'.theme_name.'/');

Or you can do this by using variable like this..

define("theme_name", "andrew");
$theme_name = theme_name;
define("LAYOUT_DIR", ROOT_DIR.'_content/layouts/themes/'.$theme_name.'/');
Sign up to request clarification or add additional context in comments.

Comments

2

In php the concatenation operator is DOT(.)

If you define a variable in php like following

define("theme_name", "andrew");

Then you have to use the variable like below

define("LAYOUT_DIR", ROOT_DIR. '_content/layouts/themes/'. theme_name . '/');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.