ERROR syntax error, unexpected T_VARIABLE

1

I'm having a problem and I'm a beginner in PHP, I do not know if it's easy to fix this error.

  

(Parse error: syntax error, unexpected T_VARIABLE in   /home/u611580299/public_html/wp-content/themes/simplicityantigo/includes/google-fonts.php   on line 1)

<?php
global $fontArrays;

$fontArrays = array(
    0 =>
    array(
        'kind' => 'webfonts#webfont',
        'family' => 'ABeeZee',
        'variants' =>
        array(
            0 => 'regular',
            1 => 'italic',
        ),
        'subsets' =>
        array(
            0 => 'latin',
        ),
    ),
    // ...
);
?>

Full archive

    
asked by anonymous 18.12.2014 / 01:45

1 answer

5

The problem here is the use of the keyword global .

global is used to reference within the scope of a function a variable in the global scope:

<?php

$a = 5;
$b = 3;

function soma(){
    $a = 1;
    $b = 2;

    return $a + $b;
}

function somaGlobal(){
    // A partir desse ponto, $a = 5 e $b = 3
    global $a, $b;

    return $a + $b;
}

echo soma();        // escreve 3
echo somaGlobal();  // escreve 8
    
18.12.2014 / 11:20