开发者

PHP Include with a twist

开发者 https://www.devze.com 2023-03-27 06:19 出处:网络
I have an include include (\'myfile.php\'); Now, I am using wordpress and to get the template path I use:

I have an include

include ('myfile.php');

Now, I am using wordpress and to get the template path I use:

<?php echo get_template_directory_uri(); ?>

My question is:

How can I use both together?

Like:

开发者_StackOverflow
<?php

include('<?php echo get_template_directory_uri(); ?>/myfile.php');

?>

Thanks


include(get_template_directory_uri() . "/myfile.php");

The include() function just takes a string parameter. Nothing special about it.


You can use the result of the function in the include, but not by echo:ing it. Just use it directly.

<?php
include(get_template_directory_uri() . '/myfile.php');
0

精彩评论

暂无评论...
验证码 换一张
取 消