简体   繁体   中英

Weird PHP error in WordPress theme

I have a problem on a WordPress theme I am developing and I need your help. I get a weird PHP error when I am try to move my functions in separated files. So when I change this:

//file: functions.php
function function1(){
...
}
require_once('functions/other_functions.php');

to this:

//file: functions.php
require_once('functions/the_functions.php');
require_once('functions/other_functions.php');

//file: functions/the_functions.php
<?php
    function function1(){
    ...
    }
?>

I get an error says:

parse error: syntax error, unexpected T_STRING in functions/the_functions.php on line 1

this error stop only whith an empty file or this

//file: functions/the_functions.php
<?php

?>

The error appears only on a Linux based server with Light server and PHP 5.3.28 and works perfect on: Windows server with Apache PHP 5.4.16, also on a Linux server with Apache and PHP 5.3.10

function1(){ is invalid.

Perhaps you meant

function someFunctionName(){

}

Function must have a space between the function declaration and the name of the function. Otherwise it is just a rogue string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM