Beginner solution A: How to define an array of file scopes in PHP

Source: Internet
Author: User
Rookie solution A: How do you define an array of file scopes in PHP?

Global $param _array = Array (' P ', ' Q ', ' CR ', ' LT ', ' Tc,m1 ', ' tc,m2 ', ' Ri,m1 ', ' ri,m2 ');

Displays syntax errors, so how do you get this array to have a scope within the file?
Or is the file scope of an array impossible to implement?
------to solve the idea----------------------
No special definition is necessary
One but define an array
$a =array (1,2,3,4,5)

Then its scope is in this file, all functions can be accessed.
------to solve the idea----------------------
Defined in a.php, then this array defaults to global variables, functions can be used directly outside the function, the function of domestic claims global $a, to use.
------to solve the idea----------------------

$num = 123;
function aa () {
Global $num;
Echo $num;
}
AA ();
?>

------to solve the idea----------------------

$param _array = Array (' P ', ' Q ', ' CR ', ' LT ', ' Tc,m1 ', ' tc,m2 ', ' Ri,m1 ', ' ri,m2 ');

function local () {
Global $param _array;
Print_r ($param _array);
}

Class localclass{

function Run () {
Global $param _array;
Print_r ($param _array);
}
}

Print_r ($param _array);
Local ();
$obj = new Localclass ();
$obj->run ();
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.