ismael84 Posted April 18, 2013 Share Posted April 18, 2013 HelloWhen I run this command-bash-3.2 $ php magmi.cli.php-mode = update-profile = default SSH to import a csv file Magento products in my shop I get this message:Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/17/10622317/html/magmi/inc/magmi_loggers.php on line 4<?php class FileLogger{protected $_fname;public function __construct($fname=null){if($fname==null){$fname=Magmi_StateManager::getProgressFile(true);}$this->_fname=$fname;$f=fopen($this->_fname,"w");if($f==false){throw new Exception("CANNOT WRITE PROGRESS FILE ");}fclose($f);}public function log($data,$type){$f=fopen($this->_fname,"a");if($f==false){throw new Exception("CANNOT WRITE PROGRESS FILE ");}$data=preg_replace ("/(\r|\n|\r\n)/", "<br>", $data);fwrite($f,"$type:$data\n");fclose($f);}}class EchoLogger{public function log($data,$type){$info=explode(";",$type);$type=$info[0];echo('<p class="logentry log_'.$type.'">'.$data."</p>");}}class CLILogger{public function log($data,$type){echo("$type:$data\n");}}?> magmi_loggers.php Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 18, 2013 Share Posted April 18, 2013 Are you running PHP 4? I don't think you can specify function visibility in PHP 4. Quote Link to comment Share on other sites More sharing options...
ismael84 Posted April 18, 2013 Author Share Posted April 18, 2013 I am running on php 5.3 Quote Link to comment Share on other sites More sharing options...
computermax2328 Posted April 18, 2013 Share Posted April 18, 2013 Argh! Unexpected T_String! These are the worst. It means you are missing something or something got added. I noticed something, look here... <?php class FileLogger { protected $_fname; public function __construct($fname=null) { if($fname==null) { Look at your $_fname variable on line 4 and then you have it in the public function differently, $fname. Is that it? It says the error is on line 4. Let me know, Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 18, 2013 Share Posted April 18, 2013 Just to humor me, what happens when you run: php -v Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 18, 2013 Share Posted April 18, 2013 Argh! Unexpected T_String! These are the worst. It means you are missing something or something got added. I noticed something, look here... <?php class FileLogger { protected $_fname; public function __construct($fname=null) { if($fname==null) { Look at your $_fname variable on line 4 and then you have it in the public function differently, $fname. Is that it? It says the error is on line 4. Let me know, That's kind of how function arguments work. You can call it whatever you want when you pass it in. See variable scope. Quote Link to comment Share on other sites More sharing options...
computermax2328 Posted April 18, 2013 Share Posted April 18, 2013 That's kind of how function arguments work. You can call it whatever you want when you pass it in. See variable scope. I know what you mean. The error is saying it is on line 4 and on line 4 he has a different variable outside of this function then he does on the inside. Plus the $_fname isn't anywhere else. It is suppose to be $fname. It is just a typo error Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 18, 2013 Share Posted April 18, 2013 No. Dude. $_fname is the property name. When you pass an argument into the function you can call it whatever you want. PHP doesn't care if you typo your variables when they're legit names. I'm sorry but you're dead wrong on that. Seriously go google PHP variable scope. Quote Link to comment Share on other sites More sharing options...
computermax2328 Posted April 18, 2013 Share Posted April 18, 2013 No need to get crazy. My bad. Quote Link to comment Share on other sites More sharing options...
Jessica Posted April 18, 2013 Share Posted April 18, 2013 How am I crazy? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.