4 Replies - 986 Views - Last Post: 14 June 2011 - 04:45 AM Rate Topic: -----

#1 jagadish_c  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 10-January 11

how to check whether a file has been included in to current file

Posted 14 June 2011 - 02:44 AM

Hi all,
I would like to know that how to check whether a file has been successfully included into current file.
Is This A Good Question/Topic? 0
  • +

Replies To: how to check whether a file has been included in to current file

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: how to check whether a file has been included in to current file

Posted 14 June 2011 - 02:50 AM

use require. that emits an error if the inclusion failed. or test with file_exists() and/or is_readable() whether it is possible to include the file.
Was This Post Helpful? 0
  • +
  • -

#3 jagadish_c  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 10-January 11

Re: how to check whether a file has been included in to current file

Posted 14 June 2011 - 02:57 AM

View PostDormilich, on 14 June 2011 - 02:50 AM, said:

use require. that emits an error if the inclusion failed. or test with file_exists() and/or is_readable() whether it is possible to include the file.

Thank you for your quick reply. I am using the below piece of code where the file by name Mail.php is being included.
<?php
 ini_set('display_errors',1);
 error_reporting(E_ALL);
 include "header.php";
 include "Mail/Mail.php";
 if(is_readable('Mail/mail.php')) 
  echo "file exists.";
 else 
  echo "not exists."; ?>

Here ini_set() and error_reporting() has been used to display errors if any. The above code is not producing any results neither the error or warning messages. Even I tried using require instead of include but not able to get any error message and getting only blank page.

This post has been edited by jagadish_c: 14 June 2011 - 03:08 AM

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: how to check whether a file has been included in to current file

Posted 14 June 2011 - 04:03 AM

depends on what header.php & mail.php do. e.g. if you do a redirect, you won’t see anything that you print.
Was This Post Helpful? 1
  • +
  • -

#5 jagadish_c  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 31
  • Joined: 10-January 11

Re: how to check whether a file has been included in to current file

Posted 14 June 2011 - 04:45 AM

View PostDormilich, on 14 June 2011 - 04:03 AM, said:

depends on what header.php & mail.php do. e.g. if you do a redirect, you won’t see anything that you print.

Thank you Dormilich. The problem was with inclusion of 'header.php' which is doing the redirect. Now the error messages can be seen after removing the header.php. Thanks again.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1