Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 分析错误:语法错误,意外'-&燃气轮机';(T_对象_运算符)_Php_Syntax Error - Fatal编程技术网

Php 分析错误:语法错误,意外'-&燃气轮机';(T_对象_运算符)

Php 分析错误:语法错误,意外'-&燃气轮机';(T_对象_运算符),php,syntax-error,Php,Syntax Error,我有一种感觉,这可能是一个简单的语法错误,我只是没有看到,因为我有一个戳周围的代码,无法找出为什么我得到上述错误。我正在编写的代码是SAMS书籍中关于构建日历类的教程。作为记录,我正在运行PHP5.4.7。下面的代码属于我将在下面展示的include。。 function date_pulldown($name) { $this->name = $name; } function setDate_global( ) { if (!this->setDate_arra

我有一种感觉,这可能是一个简单的语法错误,我只是没有看到,因为我有一个戳周围的代码,无法找出为什么我得到上述错误。我正在编写的代码是SAMS书籍中关于构建日历类的教程。作为记录,我正在运行PHP5.4.7。下面的代码属于我将在下面展示的include。。
function date_pulldown($name) {
    $this->name = $name;
}

function setDate_global( ) {
    if (!this->setDate_array($GLOBALS['$this->name'])) {
        return $this->setDate_timestamp(time());
    }

    return true;
}

function setDate_timestamp($time) {
    $this->timestamp = $time;
    return true;
}

function setDate_array($inputdate) {
    if (is_array($inputdate) &&
        isset($inputdate["mon"]) &&
        isset($inputdate["mday"]) &&
        isset($inputdate["year"])) {

        $this->timestamp = mktime(11, 59, 59, $inputdate["mon"], $inputdate["mday"], $inputdate["year"]);

        return true;
    }

    return false;       
}

function setYearStart($year) {
    $this->yearstart = $year;
}

function setYearEnd($year) {
    $this->yearend = $year;
}

function getYearStart() {
    if ($this->yearstart < 0) {
        $nowarray = getdate(time());
        $this->yearstart = $nowarray[year]-5;
    }

    return $this->yearstart;
}

function getYearEnd() {
    if ($this->yearend < 0) {
        $nowarray = getdate(time());
        $this->yearend = $nowarray[year]+5;
    }
    return $this->yearend;
}

function output() {
    if ($this->timestamp < 0) {
        $this->$setDate_global();
    }
    $datearray = getdate($this->timestamp);
    $out = $this->day_select($this->name, $datearray);
    $out .= $this->month_select($this->name, $datearray);
    $out .= $this->year_select($this->name, $datearray);
    return $out;
}

function day_select($fieldname, $datearray) {
    $out = "<select name=\"$fieldname"."[mday]\">\n";
    for ($x=1; $x<=31; $x++) {
        $out .="<option value=\"$x\"".($datearray["mday"]==($x)?" SELECTED":"").">".sprintf("%02d", $x)."\n";
    }
    $out .="</select>\n";
    return $out;
}

function month_select($fieldname, $datearray) {
    $out = "<select name=\"$fieldname"."[mon]\">\n";
    for ($x=1; $x<=12; $x++) {
        $out .="<option value=\"".($x)."\"".($datearray["mon"]==($x)?" SELECTED":"")."> ".$this->months[$x-1]."\n";
    }
    $out .="</select>\n";
    return $out;
}

function year_select($fieldname, $datearray) {
    $out = "<select name=\"$fieldname"."[year]\">";
    $start = $this->getYearStart();
    $end = $this->getYearEnd();
    for ($x=$start; $x<$end; $x++) {
        $out .="<option value=\"$x\"".($datearray["year"]==($x)?" SELECTED":"".">$x\n";
    }
    $out .="</select>\n";
    return $out;
}
}
?>
function date\u下拉列表($name){
$this->name=$name;
}
函数setDate_全局(){
如果(!this->setDate_数组($GLOBALS['$this->name'])){
返回$this->setDate_timestamp(time());
}
返回true;
}
函数setDate_时间戳($time){
$this->timestamp=$time;
返回true;
}
函数setDate_数组($inputdate){
if(是_数组($inputdate)&&
isset($inputdate[“mon”])&&
isset($inputdate[“mday”])&&
isset($inputdate[“年])){
$this->timestamp=mktime(11,59,59,$inputdate[“mon”]、$inputdate[“mday”]、$inputdate[“year”]);
返回true;
}
返回false;
}
函数setYearStart($year){
$this->yearstart=$year;
}
函数setYearEnd($year){
$this->yearend=$year;
}
函数getYearStart(){
如果($this->yearstart<0){
$nowarray=getdate(time());
$this->yearstart=$nowarray[year]-5;
}
返回$this->yearstart;
}
函数getYearEnd(){
如果($this->yearend<0){
$nowarray=getdate(time());
$this->yearend=$nowarray[year]+5;
}
返回$this->yearend;
}
函数输出(){
如果($this->timestamp<0){
$this->$setDate_global();
}
$datearray=getdate($this->timestamp);
$out=$this->day\u select($this->name,$datearray);
$out.=$this->month\u select($this->name,$datearray);
$out.=$this->year\u select($this->name,$datearray);
退回$out;
}
函数日\u选择($fieldname,$datearray){
$out=“\n”;
对于($x=1;$x个月[$x-1]。“\n”;
}
$out.=“\n”;
退回$out;
}
函数年份\u选择($fieldname,$datearray){
$out=“”;
$start=$this->getYearStart();
$end=$this->getYearEnd();
对于($x=$start;$x)
以及显示(包括)页面的代码:


示例12.4-使用date_下拉类
发件人:


致:


成立公司:



您缺少一个
$
符号:

if (!this->setDate_array($GLOBALS['$this->name'])) {
应该是

if (!$this->setDate_array($GLOBALS['$this->name'])) {

该行在
This
之前缺少一个
$
,因此
This
被视为一个常量,它不存在,因此被视为一个字符串,后面不能有
->

除了上述
if(!This
to
if(!$This

您还需要在功能
year\u select
中重新访问此行:

$out .="<option value=\"$x\"".($datearray["year"]==($x)?" SELECTED":"".">$x\n";
$out.=“$x\n”;
看起来应该更改为:
(请注意,我所做的一些更改是为了与其他函数的格式相匹配,似乎没有一致性)

$out.=.$x.“\n”;

错误是否给出了一行?#?准确完整的错误消息是什么?它对应于哪行代码?顺便说一句,在修复了您在年中的错误后,_select()。$out.=“$x\n”应该在“:”后面有一个结束符@约翰密码-很抱歉,最初的错误发生在第14行。干杯,感谢您的解释!
if (!this->setDate
$out .="<option value=\"$x\"".($datearray["year"]==($x)?" SELECTED":"".">$x\n";
$out .= "<option value=\"".$x."\"".($datearray["year"]==($x)?" SELECTED":"").">".$x."\n";