意外的分号?

时间:2017-07-12 10:24:40

标签: php

错误日志引发以下错误:Parse error: syntax error, unexpected ';' in line 11

知道我为什么会收到此错误?据我所知PHP,所有PHP语句都以分号结尾。我在这里缺少什么?

按要求提供完整代码:

<?php

if(isset($_POST['submit'])) {
    $firstName = $middleName = $lastName = $address = $mobileNumber = "";
    $password = $email = $result = "";      


    test_input($data) {

    $data = stripcslashes($data);     // <-- this is where error occurs
    $data = htmlspecialchars($data);
    $data = htmlentities($data);

    return $data;
    }

    $link = mysqli_connect("localhost","root","ilovemyself","eshop");
    if(!$link) {
        echo "Could not connect to the database !";
    } else {

        $firstName = test_input($_POST['firstName']);

    ...
    }
 }

1 个答案:

答案 0 :(得分:1)

基本上你是以错误的方式定义功能。

只需替换你的&#34; test_input&#34;阻止这一个:

    function test_input($data) {
        $data = stripcslashes($data);
        $data = htmlspecialchars($data);
        $data = htmlentities($data);
        return $data;
    }