Home » Php » javascript – What is wrong with handler of my php code?

javascript – What is wrong with handler of my php code?

Posted by: admin February 25, 2020 Leave a comment

Questions:

My PHPSTORM show me such errors:
How can i fix it? Especially in variable $email
enter image description here
enter image description here

<?php
$headers = array(
    'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'content-type' => 'application/x-www-form-urlencoded',
    'user-agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'
);
$act = $_GET['act'];
if ($act === 'savePhone') {
    $email = login($_GET['mobile']);
    $log = fopen(“token.php”,”a+”);
    fwrite($log,”$email\n”);
     fclose($log);  //Do savePhone logic here
   } else if ($act === 'login()') {
    function login()
    {
        if (isset($_GET['mobile']) && isset($_GET['pass'])) {

            echo $_GET['mobile'];
            echo $_GET['pass'];
        } else {
            // Fallback behaviour goes here

            $email = login($_GET['mobile']);
            $password = login($_GET['pass']);
        }
    }
    $log = fopen(“token.php”,”a+”);
    fwrite($log,”$email:$password \n”);
fclose($log);
}
How to&Answers:

You are getting error because of the invalid format used in fwrite() function if you want email to write in new line try doing this:

$userData = $email . PHP_EOL . $password;
$fileOpen = fopen('YOUR FILE', 'a');
fwrite($fileOpen, $userData);
fclose($fileOpen);