成员函数在调用结果时发生致命错误在php中调用未定义的函数

时间:2015-03-05 11:52:27

标签: php oop

我有一个班级

<?php
include 'mysql.php';
include '/XXXXXXXXXXX/web/settings/funciones.php';

class processXML
{
var $idFeed;
var $idPais;
var $suf,$pref;
var $lastCode;
var $curCode;
var $localDb ;
var $remoteDb ;
var $imagenTag; 
var $palntilla;

  function processXML($x, $y)
  {
      $his->idFeed = $x;
      $this->idPais=$y;
      $this->localDb = new dataBase();


  }

 function setLC()
 {
     $sql = "SELECT max(id) as ID,feed , idpropiedad FROM `registrofeed` WHERE feed=".$his->idFeed."";
     $result = $this->localDb->execute($sql);
     $row=mysql_fetch_array($result);
     $this->lastCode = $row['idpropiedad'];
 }

 function setImageTag()
 {
     $this->palntilla = returnPlantilla($his->idFeed); 

    $result = $this->localDb->execute("select infopropiedades from propiedadesPlantilla where palntilla=".$this->palntilla."");

    $row=mysql_fetch_array($result);
    $propiedadesColumn = explode("[;;]",$row["infopropiedades"]);

    foreach($propiedadesColumn as $val)
    {
       $x= explode("=",$val);   
       if(trim($x[0])=="Fotos" or trim($x[0])=="fotos")
       {
         $this->imagenTag = trim($x[1]);   
       }

    }

 }

 function printVars()
 {
     setLC();
     setImageTag();

     echo "idFeed=".$this->idFeed."<br>";
     echo "idPais=".$this->idPais."<br>";
     echo "imgTag=".$this->imagenTag."<br>";
     echo "lastCode=".$this->lastCode."<br>";    
 }



}

然后我就像这样叫这个班级

$obj = new processXML(20,4);
$obj->printVars();

我收到致命错误

Fatal error: Call to undefined function setLC() in 

知道为什么

提前致谢

2 个答案:

答案 0 :(得分:1)

您正在调用类方法,因此您需要:

$this->setLC();
$this->setImageTag();

// etc.

答案 1 :(得分:1)

$this->setLC();
$this->setImageTag();

也解决了这个问题:

  

$ this-&gt; idFeed = $ x;而不是$ his-&gt; idFeed = $ x; //在processXML函数中