Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 12369
Latest: Dwaynee
New This Month: 9
New This Week: 2
New Today: 1
Stats
Total Posts: 40207
Total Topics: 7080
Most Online Today: 79
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 2
Guests: 24
Total: 26

Author Topic: Strange SMF Behaviour when dealing with PHP classes  (Read 2282 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 657
    • View Profile
    • Homework Clinic - Your Academic Lifeline
Strange SMF Behaviour when dealing with PHP classes
« on: February 20, 2017, 11:27:54 pm »
When I try loading a class inside an SMF template, i.e. index.template.php

Code: [Select]
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?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15104
    • View Profile
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #1 on: February 20, 2017, 11:30:14 pm »
Whats the error
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 657
    • View Profile
    • Homework Clinic - Your Academic Lifeline
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #2 on: February 20, 2017, 11:36:49 pm »
Mostly all

PHP Notice:  Undefined variable: ...

The exact same code placed into /example.php works perfectly.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15104
    • View Profile
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #3 on: February 21, 2017, 12:05:48 am »
both have errors just smf is displaying those errors
« Last Edit: February 21, 2017, 12:09:21 am by SMFHacks »
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 657
    • View Profile
    • Homework Clinic - Your Academic Lifeline
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #4 on: February 21, 2017, 12:07:09 am »
In /example.php, those errors don't exist.

Would it help to upload the class?

http://naveedurrehman.com/demo/phpequations/?page=demo#output

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15104
    • View Profile
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #5 on: February 21, 2017, 12:09:52 am »
If you add ini_set("display_errors",1); to the other script they probably will show. On the very first line.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 657
    • View Profile
    • Homework Clinic - Your Academic Lifeline
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #6 on: February 21, 2017, 12:11:27 am »
You're right :-\

What's going on then?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15104
    • View Profile
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #7 on: February 21, 2017, 12:32:34 am »
SMF displays errors by default.
Index.php important
Code: [Select]
error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
And sources/errors.php
Code: [Select]
// 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;
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 657
    • View Profile
    • Homework Clinic - Your Academic Lifeline
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #8 on: February 21, 2017, 12:33:35 am »
So do you think the script is faulty or an SMF thing?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15104
    • View Profile
Re: Strange SMF Behaviour when dealing with PHP classes
« Reply #9 on: February 21, 2017, 12:37:13 am »
Script is faulty shouldn't have undefined errors.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
5395 Views
Last post September 24, 2007, 01:31:08 am
by Scy
3 Replies
4672 Views
Last post November 01, 2008, 10:24:04 am
by Jim332525
1 Replies
2963 Views
Last post July 21, 2009, 11:13:04 pm
by SMFHacks
3 Replies
3957 Views
Last post November 29, 2009, 10:40:40 am
by Vincent Volmer
2 Replies
2310 Views
Last post April 08, 2015, 03:51:23 am
by eldritch1969

+- Recent Topics

Font question by SMFHacks
May 27, 2020, 08:15:26 am

Error message with latest SMF 2.1 Github build by Hatshepsut
May 25, 2020, 01:43:26 am

smfblog not working on 2.0.17 by tech9
May 20, 2020, 01:44:34 pm

Copyright removal by stbc
May 18, 2020, 01:27:57 am

Mod Verified User i can't square the image by Rock Lee
May 07, 2020, 07:56:10 pm

SMF4Mobile 2.0 released for SMF 2.0.x by SMFHacks
May 06, 2020, 12:13:14 pm

SMF Social Login Pro - Discontinued? by Nicole
May 02, 2020, 05:47:04 pm

Likes by SMFHacks
April 30, 2020, 09:50:35 pm

Upgrade Issue - by SMFHacks
April 28, 2020, 12:40:13 pm

Issues regarding Licenses and Domain by SMFHacks
April 28, 2020, 10:59:41 am

Powered by EzPortal