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

Deleted Delivery but material wont return
We deleted a delivery but the material its still pending.

We made a reverse goods movemen

Display the user's weight lost in the past week
Hello everyone,

I am working on a weight loss app for my site, and I want to display the user

RSS feed - FeedList for WordPress
Hi,

I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

WHYISNT THIS MYSQL STATEMNT NOT WORKING? (php)
caps because its absolutely rediculous.
i dontunderstand why its not working. there is a column c

session checking in page load
hai all I have a web site is www.Mryas.com in this my login page is Page1.aspx its co

Strip Slashes Help
I've got a script that i've downloaded of the net to edit multiple fields from my sql database, and

PHP search multiple input field box help
I am having a problem with my search script. At current it will simply search by a selected date whi

PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see

try catch error
I have been trying try catch but, I can't get it to work. The code opens a non existing file called

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