SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Thread: __file__

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    __file__

    Hi,

    Is __FILE__ depreciated?

    Am I correct in thinking that it contains the current scripts absolute path and when its dirname(__FILE__) it shows the absolute path to the directory in which the current script is?

    Thanks.

  2. #2
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I don't think it is deprecated... I use dirname(__FILE__) all the time!

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What makes you think its deprecated?

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,849
    Mentioned
    16 Post(s)
    Tagged
    1 Thread(s)
    No, he thinks its depreciated.

    like __FILe__ or something, maybe its linked to the UK pound.

  5. #5
    ¬.¬ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,009
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    dirname( __FILE__ ) === __DIR__ in PHP 5.3
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  6. #6
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,004
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If __FILE__ is meant to be deprecated what would be best alternate of it then?

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All i asked was whether or not __FILE__ was depreciated.

    I asked it because in i've never come across it during my time learning PHP.

  8. #8
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,004
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by L4DD13 View Post
    All i asked was whether or not __FILE__ was depreciated.

    I asked it because in i've never come across it during my time learning PHP.
    Nope, AFAIK, it is not deprecated yet and you can fairly use it.

  9. #9
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,849
    Mentioned
    16 Post(s)
    Tagged
    1 Thread(s)
    you might be interested in magic constants then, and core predefined constants, which includes my favourite

    PHP_EOL

    (PHP End Of Line)

    Which puts in the correct EOL for your OS.

    echo 'a line' . PHP_EOL ;

    I find it far better than "\n"; once I remembered to use it of course.

  10. #10
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,117
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Remember for emails to use \r\n always though. \n is not valid over the SMTP protocol

  11. #11
    SitePoint Evangelist
    Join Date
    Jun 2008
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, thanks guys.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •