PHP parsing error (unexpected T_IF)

I can not find why I get

Parse error: syntax error, unexpected "if" (T_IF) in /Applications/XAMPP/xamppfiles/htdocs/oop/index.php on line 8

I checked for missing half-columns / parentheses / curly braces but can't find anything! There are several other files to which they refer. Should I publish them as well?

( getInstanceis the static method in the class db)
( countand getare methods in the class db)

Thanks in advance!

<?php

require_once 'core/init.php';

$user = DB::getInstance()->get('users', array('username', '=', 'bob'));

if(!$user->count()) {
    echo 'No user';
} else {
    echo 'OK';
}

?>

init.php looks like this:

<?php 

session_start();

$GLOBALS['config'] = array(

'mysql' => array(
    'host' => '127.0.0.1',
    'username' => 'root',
    'password' => '',
    'db' => 'oop'),

'remember' => array(
    'cookie_name' => 'hash',
    'cookie_expiry' => 604800),

'session' => array(
    'session_name' => 'user')
);

spl_autoload_register(function($class) {
    require_once 'classes/' . $class . '.php';
});

require_once 'functions/sanitize.php';
?>
+3
source share
1 answer

0xefbbbf ( UTF-8 U + FEFF, ) 6:

$ hexdump -C index.txt
00000000  3c 3f 70 68 70 0a 0a 72  65 71 75 69 72 65 5f 6f  |<?php..require_o|
00000010  6e 63 65 20 27 63 6f 72  65 2f 69 6e 69 74 2e 70  |nce 'core/init.p|
00000020  68 70 27 3b 0a 0a 24 75  73 65 72 20 3d 20 44 42  |hp';..$user = DB|
00000030  3a 3a 67 65 74 49 6e 73  74 61 6e 63 65 28 29 3b  |::getInstance();|
00000040  0a 24 75 73 65 72 2d 3e  67 65 74 28 27 75 73 65  |.$user->get('use|
00000050  72 73 27 2c 20 61 72 72  61 79 28 27 75 73 65 72  |rs', array('user|
00000060  6e 61 6d 65 27 2c 20 27  3d 27 2c 20 27 62 6f 62  |name', '=', 'bob|
00000070  27 29 29 3b ef bb bf 0a  0a 69 66 28 21 24 75 73  |'));.....if(!$us|
00000080  65 72 2d 3e 63 6f 75 6e  74 28 29 29 20 7b 0a 09  |er->count()) {..|
00000090  65 63 68 6f 20 27 4e 6f  20 75 73 65 72 27 3b 0a  |echo 'No user';.|
000000a0  7d 20 65 6c 73 65 20 7b  0a 09 65 63 68 6f 20 27  |} else {..echo '|
000000b0  4f 4b 27 3b 0a 7d 0a 0a  3f 3e                    |OK';.}..?>|
000000ba

, , , .

PHP (n undefined) , , , if ( ).

.

+5
source

All Articles