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:

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

PHP Search Issue
Hi, I am using the following code to search and return flights from a database. The user searches by

Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.<

Calander Basic Spript help
hi, just starting out with PHP and have the following script:

<?php
//This gets t

Not "Just Another" MMORPG - text based.
Hello,

I've been learning MySQL and PHP for the last 2-3 years.
Though, I've had long paus

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to ret

Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to

Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba

Linux socket programming
Where can I find a good introduction to socket programming?

user administration
Dear @all,

what I have to do to set the user defaults for new users. At the moment I woul

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