SMFHacks.com
Modifications/Themes => General SMF Forum => Topic started by: shuban on February 20, 2017, 11:27:54 pm
-
When I try loading a class inside an SMF template, i.e. index.template.php
include("/to_path_way/somefunction.class.php");
$equations = new phpequations();
$context['equation'] = $equations->solve("x-y=-4
x+z=8
x-y-z=10");
And I print out $context['equation'], it gives me hundreds of errors, but when I don't use anything SMF related, it works as it should.
What's the trick to getting classes to work with SMF's templates?
-
Whats the error
-
Mostly all
PHP Notice: Undefined variable: ...
The exact same code placed into /example.php works perfectly.
-
both have errors just smf is displaying those errors
-
In /example.php, those errors don't exist.
Would it help to upload the class?
http://naveedurrehman.com/demo/phpequations/?page=demo#output
-
If you add ini_set("display_errors",1); to the other script they probably will show. On the very first line.
-
You're right :-\
What's going on then?
-
SMF displays errors by default.
Index.php important
error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
And sources/errors.php
// Ignore errors if we're ignoring them or they are strict notices from PHP 5 (which cannot be solved without breaking PHP 4.)
if (error_reporting() == 0 || (defined('E_STRICT') && $error_level == E_STRICT && (empty($modSettings['enableErrorLogging']) || $modSettings['enableErrorLogging'] != 2)))
return;
-
So do you think the script is faulty or an SMF thing?
-
Script is faulty shouldn't have undefined errors.