can somebody make sense of this? This code leaves an irritating "undefined variable" php Notice on my page. First I have this in my header in Wordpress. (BTW, I'm picking up another dev's code)
$head .= "
<link rel='profile' href='http://gmpg.org/xfn/11' />
<link rel='stylesheet' type='text/css' media='all' href='".get_bloginfo( 'stylesheet_url' )."' />
<link rel='pingback' href='".get_bloginfo( 'pingback_url' )."' />
";
ob_start();
wp_head();
$head .= ob_get_clean();
Then this line of code is included in a separate file. <?=$head;?>
<--- What's this?
Removing this last line actually breaks parts of wordpress. I'm happy to leave it in but how do I remove the error Notice?
And what's happening in this code here? When I try to declare the $head variable like this:
$head = null;
It breaks everything.. I'm stumped. I know I need to leave it in. But I can't declare it. So php keeps up that notice. Ideas? Thanks.
Just remove the .=
so that it is assigning a value to the $html
rather than appending to it. You cannot append null
to a string, which is why your second attempt failed. You could initialize it to an empty string, but it's an unnecessary extra step.
$head = "
<link rel='profile' href='http://gmpg.org/xfn/11' />
<link rel='stylesheet' type='text/css' media='all' href='".get_bloginfo( 'stylesheet_url' )."' />
<link rel='pingback' href='".get_bloginfo( 'pingback_url' )."' />
";
Collected from the Internet
Please contact javaer1[email protected] to delete if infringement.
Comments