TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Parse error: syntax error, unexpected T_ECHO in -> regexp code on line 1 (http://www.talkphp.com/advanced-php-programming/5776-parse-error-syntax-error-unexpected-t_echo-regexp-code-line-1-a.html)

Torsten 02-01-2011 09:24 PM

Parse error: syntax error, unexpected T_ECHO in -> regexp code on line 1
 
Code:

Parse error: syntax error, unexpected T_ECHO in D:\Webserver\Projekte\de.unique.labs.tests\Template System\class\extensions\extensionArrayParse.php(8) : regexp code on line 1

Fatal error: preg_replace() [<a href='function.preg-replace'>function.preg-replace</a>]: Failed evaluating code: echo 'testArray' in D:\Webserver\Projekte\de.unique.labs.tests\Template System\class\extensions\extensionArrayParse.php on line 8

The Code Parse is

Code:

while( preg_match( "/" .$this->leftDelimiterF ."loop name=\"(.*)\"".$this->rightDelimiterF ."/isUe", $this->template)){
                        $this->template = preg_replace( "/" .$this->leftDelimiterF ."loop name=\"(.*)\""                                                .$this->rightDelimiterF."/isUe",
                                "echo '\\1'",
                                $this->template );
                       
}

Could someone help me I don't find the mistake :-$

tony 02-01-2011 11:08 PM

it says that the problem is at echo 'testArray' but I don't see any of that in the code you provided.

sketchMedia 02-02-2011 02:28 PM

The problem is you have given the regex the 'e' modifier, which means evaluate the replacement as php code.

Do you really need to do this? What are you trying to do?

Torsten 02-03-2011 02:08 PM

Iam Trying to develope my own Template System. But I stuck with the {loop Syntax for a Array.

Could someone help me there?

Array
Code:

$array = array('0' => array('userName' => 'Tester','userID' => '1','groupID' => '1','groupName' => 'Admin'),'1' => array('userName' => 'Tester2','userID' => '2','groupID' => '2','groupName' => 'Miglied'));
$tpl->assign('testArray',$array);

Template Code
Code:

<div>
{loop name="testArray"}
 <p>{$value.userName}</p>
{/loop}
</div>

There should be displayed in the Template
<div>
<p>Tester</p>
<p>Tester2</p>
</div>


All times are GMT. The time now is 10:03 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0