Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43260
Total Topics: 7518
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 1
Guests: 235
Total: 236

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

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
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: 16436
    • 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: 665
    • View Profile
    • Biology Forums
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: 16436
    • 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: 665
    • View Profile
    • Biology Forums
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: 16436
    • 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: 665
    • View Profile
    • Biology Forums
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: 16436
    • 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: 665
    • View Profile
    • Biology Forums
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: 16436
    • 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
6734 Views
Last post September 24, 2007, 01:31:08 am
by Scy
3 Replies
5824 Views
Last post November 01, 2008, 10:24:04 am
by Jim332525
1 Replies
4287 Views
Last post July 21, 2009, 11:13:04 pm
by SMFHacks
3 Replies
5863 Views
Last post November 29, 2009, 10:40:40 am
by Vincent Volmer
2 Replies
3357 Views
Last post April 08, 2015, 03:51:23 am
by eldritch1969

+- Recent Topics

No thumbnails on new uploads by Tonyvic
Today at 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal