Last active
December 23, 2015 08:59
-
-
Save dbernar1/6611284 to your computer and use it in GitHub Desktop.
get_template_part() vs. require - variable scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hello = 'world'; | |
get_template_part( 'hello' ); | |
require 'hello.php'; | |
function get_template_part( $filename ) { | |
require $filename . '.php'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, <?php echo $hello ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello, | |
Hello, world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment