drba1172
2015-03-05 11:52
浏览 44
已采纳

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

I have a class

<?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>";    
 }



}

Then I am calling the class like this

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

I am getting a fatal error

Fatal error: Call to undefined function setLC() in 

Any idea why

Thanks in advance

图片转代码服务由CSDN问答提供 功能建议

我有一个类

 &lt;?php 
include  'mysql.php'; 
include'/XXXXXXXXXXX/web/settings/funciones.php';
nnclass processXML 
 {
var $ idFeed; 
var $ idPais; 
var $ suf,$ pref; 
var $  lastCode; 
var $ curCode; 
var $ localDb; 
var $ remoteDb; 
var $ imagenTag;  
var $ palntilla; 
 
函数processXML($ x,$ y)
 {
 $ his-&gt; idFeed = $ x; 
 $ this-&gt; idPais = $ y; 
 $ this-  &gt; localDb = new dataBase(); 
 
 
} 
 
函数setLC()
 {
 $ sql =“SELECT max(id)as ID,feed,idpropiedad FROM`registrofeed` WHERE feed  =“。$ his-&gt; idFeed。”“; 
 $ result = $ this-&gt; localDb-&gt; execute($ sql); 
 $ row = mysql_fetch_array($ result); 
 $ this-&gt  ; lastCode = $ row ['idpropiedad']; 
} 
 
函数setImageTag()
 {
 $ this-&gt; palntilla = returnPlantilla($ his-&gt; idFeed);  
 
 $ result = $ this-&gt; localDb-&gt; execute(“从propiedadesPlantilla中选择infopropiedades,其中palntilla =”。$ this-&gt; palntilla。“”); 
 
 $ row = mysql_fetch_array($ result  ); 
 $ propiedadesColumn = explode(“[;;]”,$ row [“infopropiedades”]); 
 
 foreach($ propiedadesColumn as $ val)
 {
 $ x = explode(“=”  ,$ VAL);  
 if(trim($ x [0])==“Fotos”或trim($ x [0])==“fotos”)
 {
 $ this-&gt; imagenTag = trim($ x [1  ]);  
 
 
 
} 
 
} 
 
函数printVars()
 {
 setLC(); 
 setImageTag(); 
 
 echo“idFeed =”。$ this-&gt  ; idFeed。“&lt; br&gt;”; 
 echo“idPais =”。$ this-&gt; idPais。“&lt; br&gt;”; 
 echo“imgTag =”。$ this-&gt; imagenTag。“&lt;  br&gt;“; 
 echo”lastCode =“。$ this-&gt; lastCode。”&lt; br&gt;“;  
} 
 
 
 
 
 
} 
   
 
 

然后我像这样调用类

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

我收到致命错误

 致命错误:调用未定义的函数setLC()
   
 
 

知道原因吗 < p>提前致谢

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzhansong5785 2015-03-05 11:53
    已采纳

    You are calling a class method, so you need:

    $this->setLC();
    $this->setImageTag();
    
    // etc.
    
    已采纳该答案
    打赏 评论
  • dongyun3335 2015-03-05 11:57
    $this->setLC();
    $this->setImageTag();
    

    also fix this:

    $this->idFeed = $x; instead of $his->idFeed = $x; // in processXML function

    打赏 评论

相关推荐 更多相似问题