• Resolved wahoofive

    (@wahoofive)


    The “global” keyword doesn’t seem to work.

    [insert_php]
    $name = 'Mary';
    function showName()
    {
    	global $name;
    	 echo 'My name is ' . $name;
    }
    showName();
    [/insert_php]

    This just prints “My name is”. In this simple case, I could pass the name as a parameter, but if it’s a large variable and I’m calling the function numerous times it’s pretty inefficient.

    https://ww.wp.xz.cn/plugins/insert-php/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘globals?’ is closed to new replies.