Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57187 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9236 invoked from network); 4 Jan 2012 16:34:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2012 16:34:30 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:35170] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/3A-50667-49F740F4 for ; Wed, 04 Jan 2012 11:34:29 -0500 Received: by qcsd16 with SMTP id d16so10892622qcs.29 for ; Wed, 04 Jan 2012 08:34:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tdifspzzC0H+ZqfHrU7Q85wYtTVxmCF4HvKvmiYKjbU=; b=i5j3mLTgHmxhLCKj6VG418KMZrKGFSDjxfj/4Kqs2FyafwHEKQweZNkvwEsXsSu28x zesezLJfDpwZhHzWx++S1dxrXxmffzZTOqxuUfbnP/L76b5Wzhf9EfzT2XoTWRsHqref VTkI4tnQhrhXClVMiwKTWWD3Zg50JuKtzdoZ0= MIME-Version: 1.0 Received: by 10.224.197.73 with SMTP id ej9mr67713409qab.30.1325694865955; Wed, 04 Jan 2012 08:34:25 -0800 (PST) Received: by 10.229.54.140 with HTTP; Wed, 4 Jan 2012 08:34:25 -0800 (PST) In-Reply-To: References: Date: Wed, 4 Jan 2012 17:34:25 +0100 Message-ID: To: Keloran Cc: PHP Internals Content-Type: multipart/alternative; boundary=20cf300fb2b990dbe504b5b66397 Subject: Re: [PHP-DEV] Feature Request From: tyra3l@gmail.com (Ferenc Kovacs) --20cf300fb2b990dbe504b5b66397 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Jan 4, 2012 at 5:18 PM, Keloran wrote: > I dont seem to have the karma for doing this in RFC so ill propose it her= e, > and once karma make an RFC > > Is it possible to have a 2nd option on file_exists so that it returns the > path you specified > > --Example > $cFile =3D file_exists("/file/located/here.php", true); > > and if that exists it will return > /file/located/here.php > > instead of true > > --Reason > the reason for this is simple actually at the moment if you want to inclu= de > a file for usage but want to check it exists you have todo the following > if (file_exists("/file/located/here.php")) { > $cFile =3D "/file/located/here.php"; > } > > which can if your doing lots of checking alot of extra code for no reason= , > or if you want to use variables, lots of louse variables just for somethi= ng > that could be pulled from the request > as others mentioned that you can use realpath for that. However realpath doesn't support resolving against the include path, so depending on your usecase http://php.net/manual/en/function.stream-resolve-include-path.php would be a better idea. This still doesn't solve the potential race condition in your example (the file could have been deleted or moved between your check and the actual include/open call. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --20cf300fb2b990dbe504b5b66397--