PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Parsing problem (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Parsing problem


#6154
tarotray (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Parsing problem 6 Months, 2 Weeks ago Karma: 0  
I do have a problem with the plug-in.

I am merely adding a copyright year into the content like this:
<p>All content is &copy; 2009-<?php echo (new DateTime)->format("Y"); ?> <strong>Goaheadspace</strong> All rights reserved.</p>
Then the result is:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /home4/tarotray/public_html/web/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code on line 1

I looked at the code and haven't quite figured it out yet. Could this be an issue with the Joomla version (3.2.3) or the PHP version (5.3.28)? Otherwise, I think it may be the way in which you parse the php line.

In the end, it seems that using:
<p>All content is &copy; 2009-<?php echo date("Y"); ?> <strong>Goaheadspace</strong> All rights reserved.</p> works fine.

So, I'm very thankful for your work and hope this comment helps you improve the code (presuming I am right about the problem being in the code).
 
  The administrator has disabled public write access.

#6155
kksou (Admin)
Admin
Posts: 1728
graph
User Online Now Click here to see the profile of this user
Re:Parsing problem 6 Months, 1 Week ago Karma: 27  
Hi Tarotray,

DirectPHP uses standard PHP eval() statement. If it runs in PHP, it should also run in DirectPHP.

For your case, it will work if you use the following:
Code:
$date = new DateTime('now', new DateTimeZone('America/Los_Angeles'));
echo $date->format('Y');
Try to create a standalone .PHP file and put the following line:
Code:
echo new DateTime('now', new DateTimeZone('America/Los_Angeles'))->format('Y-m-d');
It will give the same error message "Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /home4/tarotray/public_html/web/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code on line 1" In PHP, when you use "new" to create a new object, usually we have to put the newly created object into a variable before we can call its method. For DirectPHP, I usually try the commands in a standalone .PHP file first, make sure it works before I transfer them into DirectPHP. Warm Regards, /kksou
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2012. kksou.com. All Rights Reserved