Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

PHP Notice: how to identify offending line in template

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
phil_karasinsky
Smarty n00b


Joined: 14 Nov 2015
Posts: 4

PostPosted: Sun May 01, 2016 4:33 pm    Post subject: PHP Notice: how to identify offending line in template Reply with quote

In my Apache error log, I sometimes see PHP Notices of this kind:

Code:

[01-May-2016 12:03:05 America/New_York] PHP Notice:  Undefined offset: 1 in /some_path/blah.tpl.php on line 78


I understand the nature of the notice and want to improve my app code or smarty template (as appropriate).

However, line 78 (in this example) is the line number in the compiled template generated by Smarty, and not the line number of the code in my Smarty template that triggered the Notice.

Unfortunately, the template involved has a morass of arrays with multiple dimensions of subscripts and it's not obvious which is involved. Yes, yes, I know, my initial writing should have anticipated these issues better. But what's done is done, and I've learnt my lesson, honest Smile

Is there a convenient and methodical way to find where in the template source the line is that triggered the PHP Notice (other than viewing the source and compiled versions side by side and working out by eye what corresponds to what), given the line number in the compiled version?

Edit: I've identified the line as the correspondence between the compiled code and the template source is fairly obvious, but would be interested to know if there is a way to automate this process somewhat.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP