Jump to content

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTIO


ismael84

Recommended Posts

Hello

When 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

Link to comment
Share on other sites

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,

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.