Filename and Line Number Custom Error


Posted on 16th Feb 2014 07:03 pm by admin

I have a class, with a method that accepts 2 parameters. I would like to output error messages.

So, lets say a new file is created, and my class is used in that file. We will call that file test.php lets say they use this method with two parameters on line 105 but... they forget to add the second parameter. I currently display this message:

Did you know?Explore Trending and Topic pages for more stories like this.
print("<p><b>Warning:</b> Class <b>" . __class__ . "</b> requires 2 parameters, 1 given.</p>");

Warning: Class ClassName requires 2 parameters, 1 given.

I would like to change it to also include the file name and the line number, so the final result would look like this:

Warning: Class ClassName requires 2 parameters, 1 given in /home/user/www/test.php on line 105.

How can I get the file name and line number from within the class? Is it possible?
No comments posted yet

Your Answer:

Login to answer
325 Like 20 Dislike
Previous forums Next forums
Other forums

$action = "insert"; //$action = $_GET['action'];
$action = "insert";
//$action = $_GET['action'];

why is this invalid type? I am

Putting double spaces instead of single spaces
Im looking at trying to replace all single spacing between fields with double spacing

At pres

Multiple Pages
Hi. Im very new to php. I'm trying to create a basic login/registration page.

So I have a bas

Array help
Hello i got this code to fetch data from database but it is not working it displays
7
Array

Allowing ' and "
Hello everyone,

I am creating a form where users submit information to go into a database. I

upload control not working with update panel
Hi,

I am working with Asp.Net FileUpload control with ajax update panel,

if i use the

php web service error
hey guys,
I'm working on a project requires the use of web services. I've been trying a few tutor

PHP5/Zend 2.0 - Resources
PHP5 Snapshots
http://snaps.php.net/

ZEND 2.0 Feature Overview and Design (PDF File

Only add new information from XML to MySQL
What I am doing, is taking a xml file, and adding the values to a database. However, what I want to

Word Trimming
Hi Guys & Gals!!

Hope you are all ok....

I need some help with the following

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash