including a file if it exists

This is a discussion on including a file if it exists within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hello, I am just wondering if there is a standard php function that includes a file if it is exists, ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-26-2005
Martien van Wanrooij
 
Posts: n/a
Default including a file if it exists

Hello,

I am just wondering if there is a standard php function that includes a file
if it is exists, or something else that avoids error messages when the file
doesn't exist. It is quite easy to write a function to reach this (I
actually did) but I couldn't find any standard function although it might be
available.

Martien


Reply With Quote
  #2 (permalink)  
Old 03-26-2005
Oli Filth
 
Posts: n/a
Default Re: including a file if it exists

Martien van Wanrooij wrote:
> Hello,
>
> I am just wondering if there is a standard php function that includes a file
> if it is exists, or something else that avoids error messages when the file
> doesn't exist. It is quite easy to write a function to reach this (I
> actually did) but I couldn't find any standard function although it might be
> available.
>


@include "file.txt";


--
Oli
Reply With Quote
  #3 (permalink)  
Old 03-26-2005
Martien van Wanrooij
 
Posts: n/a
Default Re: including a file if it exists


"Oli Filth" <catch@olifilth.co.uk> schreef in bericht
news:Wdf1e.226$AZ6.152@newsfe3-win.ntli.net...
> @include "file.txt";

Thank you _very_ much, obviously I am not very good at Google-ing but this
is really helpful :)

Martien


Reply With Quote
  #4 (permalink)  
Old 03-26-2005
Kimmo Laine
 
Posts: n/a
Default Re: including a file if it exists

"Martien van Wanrooij" <info_removethis_@martienvanwanrooij.nl> kirjoitti
viestissä:cIf1e.5614$Mw3.1005@amstwist00...
>
> "Oli Filth" <catch@olifilth.co.uk> schreef in bericht
> news:Wdf1e.226$AZ6.152@newsfe3-win.ntli.net...
>> @include "file.txt";

> Thank you _very_ much, obviously I am not very good at Google-ing but this
> is really helpful :)
>


In case you were eondering what it does: the @-sign before a command
suppresses possible error and warning messages.


Reply With Quote
  #5 (permalink)  
Old 03-26-2005
Martien van Wanrooij
 
Posts: n/a
Default Re: including a file if it exists


"Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> schreef in bericht
news:d24309$m51$1@phys-news1.kolumbus.fi...
> In case you were eondering what it does: the @-sign before a command
> suppresses possible error and warning messages.

Yes I found it out now, but I never had noticed that option, thanx :)


Reply With Quote
  #6 (permalink)  
Old 03-28-2005
Marc Nadeau
 
Posts: n/a
Default Re: including a file if it exists

Martien van Wanrooij a écrit:

> Hello,
>
> I am just wondering if there is a standard php function that includes a
> file
> if it is exists, or something else that avoids error messages when the
> file doesn't exist. It is quite easy to write a function to reach this (I
> actually did) but I couldn't find any standard function although it might
> be available.
>
> Martien


if file_exists("path/to/file.inc"){
include("path/to/file.inc")
}

--
__________________________________________________ __________
/ Le nombre partage, organise le monde. Fernand Braudel, Les \
\ structures du quotidien /
------------------------------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:05 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0