Max
Max

Reputation: 180

file-exists check for php's auto_prepend_file

I currently have the situation that in my vhost.conf i have an entry to automatically include a file to start profiling:

php_value auto_prepend_file /home/xhprof/include/xhprof.php

This thing is in SVN and might be checked out by people who don't have xhprof installed on their system. The consequence is, that xhprof.php is not found and PHP throws an error.

Does anybody know, if there's a possibility to check, if this file is there, before including?

thx in advance :)

Upvotes: 3

Views: 730

Answers (1)

aichingm
aichingm

Reputation: 796

Do it like this:

fileX.php:

if(is_file("/home/xhprof/include/xhprof.php")){ include '/home/xhprof/include/xhprof.php'; }

vhost.conf:

php_value auto_prepend_file path/to/fileX.php

there is a function called: is_file()

Upvotes: 2

Related Questions