Author Topic: PHP 5.3  (Read 615 times)

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
PHP 5.3
« on: March 25, 2009, 06:48:13 AM »
Well, we're getting closer to an official release of 5.3. Did anyone else miss this little gem:

__DIR__

This new magic constant will do the exact same thing as:

dirname (__FILE__)

My fingers thank the PHP developers for shortening the amount of work they need to do to include a file ;)
Idiocy - Never underestimate the power of stupid people in large groups.


Offline maclof

  • Level 6
  • *
  • Posts: 23
  • Reputation: +0/-0
    • View Profile
    • Operation Zombie
Re: PHP 5.3
« Reply #1 on: March 25, 2009, 06:52:00 AM »
Oh sweet, :D will be using this then ;)

Offline Tribal

  • Level 22
  • *
  • Posts: 256
  • Reputation: +1/-1
    • View Profile
Re: PHP 5.3
« Reply #2 on: May 05, 2009, 05:26:41 PM »
Lol.

Can wait, think about the saved bytes!

Offline Crazy-T

  • Level 19
  • *
  • Posts: 197
  • Reputation: +0/-0
  • Building Games
    • View Profile
Re: PHP 5.3
« Reply #3 on: June 06, 2009, 04:09:37 AM »
Well, we're getting closer to an official release of 5.3. Did anyone else miss this little gem:

__DIR__

This new magic constant will do the exact same thing as:

dirname (__FILE__)

My fingers thank the PHP developers for shortening the amount of work they need to do to include a file ;)

You can just include files like:
Code: [Select]
<?php //for colors!!
include("filename.php");              //shorter!
include_once("filename.php");      //longer!

include(DIRNAME(__FILE__) .'/somefile.php');          //Even longer.
include_once(DIRNAME(__FILE__) .'/somefile.php');  //Even even longer!.

include($_SERVER['DOCUMENT_ROOT'] .'/somefile');               //even even even longer.
include_once($_SERVER['DOCUMENT_ROOT'] .'/fomefile.php');  //100x longer lol.
I would just use
Code: [Select]
<?php //for colors!!
include('Somefile.php');
or for database connection i would use require
Crazy-T

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: PHP 5.3
« Reply #4 on: June 06, 2009, 09:08:36 AM »
Yes, you can include them that way. However PHP blows up if you're including a file that also includes another file if you don't include the absolute path to that file.

This is because PHP uses its internal path variable and doesn't reset it once inside of an included file to reflect the new location. Unless they're all in the same directory.
Idiocy - Never underestimate the power of stupid people in large groups.


 


SimplePortal 2.3.3 © 2008-2010, SimplePortal