Php error: unexpected '$ staff'

Source: Internet
Author: User
This is the source code: {code...} and then the error: Parseerror: syntaxerror, unexpected & #039; $ staff & #039; (T_VARIABLE) inD: wampwwwtestquery. phponline4 this is the source code:


   "x","number" => "101","sex" => "male","job" => "manager"),        array("name" => "y","number" => "102","sex" => "male","job" => "manager"),        array("name" => "z","number" => "103","sex" => "male","job" => "manager"),    );if ($_SERVER["REQUEST_METHOD"] == "GET") {    search();}elseif ($_SERVER["REQUEST_METHOD"] == "POST") {    create();}function search() {    if (!isset($_GET["number"]) || empty($_GET["number"])) {        echo "error";        return;    }    global $staff    $number = $_GET["number"];    $result = "error";    foreach ($staff as $key => $value) {        if ($value["number"] == $number) {            $result = "The person's ID is".$value["number;"]."He's name is".$value["name;"]."And sex is".$value["sex"]."The job".$value["job"];            break;        }    }    echo $result;}function create() {    if (!isset($_POST["name"]) || empty($_POST["name"]) ||        !isset($_POST["number"]) || empty($_POST["number"]) ||        !isset($_POST["sex"]) || empty($_POST["sex"]) ||        !isset($_POST["job"]) || empty($_POST["job"]) {        echo "error";        return;    }    echo "The person".$_POST["name"]."save success";} ?> 

Then an error is reported:
Parse error: syntax error, unexpected '$ staff' (T_VARIABLE) in D: \ wamp \ www \ test \ query. php on line 4

Reply content:

This is the source code:


   "x","number" => "101","sex" => "male","job" => "manager"),        array("name" => "y","number" => "102","sex" => "male","job" => "manager"),        array("name" => "z","number" => "103","sex" => "male","job" => "manager"),    );if ($_SERVER["REQUEST_METHOD"] == "GET") {    search();}elseif ($_SERVER["REQUEST_METHOD"] == "POST") {    create();}function search() {    if (!isset($_GET["number"]) || empty($_GET["number"])) {        echo "error";        return;    }    global $staff    $number = $_GET["number"];    $result = "error";    foreach ($staff as $key => $value) {        if ($value["number"] == $number) {            $result = "The person's ID is".$value["number;"]."He's name is".$value["name;"]."And sex is".$value["sex"]."The job".$value["job"];            break;        }    }    echo $result;}function create() {    if (!isset($_POST["name"]) || empty($_POST["name"]) ||        !isset($_POST["number"]) || empty($_POST["number"]) ||        !isset($_POST["sex"]) || empty($_POST["sex"]) ||        !isset($_POST["job"]) || empty($_POST["job"]) {        echo "error";        return;    }    echo "The person".$_POST["name"]."save success";} ?> 

Then an error is reported:
Parse error: syntax error, unexpected '$ staff' (T_VARIABLE) in D: \ wamp \ www \ test \ query. php on line 4

$staffHeader () does not use a semicolon;End. Syntax error.
Lines 21 and 36 also have
It is better for beginners to use an ide.

The change is as follows:


   "x","number" => "101","sex" => "male","job" => "manager"),        array("name" => "y","number" => "102","sex" => "male","job" => "manager"),        array("name" => "z","number" => "103","sex" => "male","job" => "manager"),    );

Rows 22 and 36 are also incorrect.

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.