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

CURL question
i am wondering if it's possible to use multi curl with login something like

login once to web

calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same

shift numbers with paging
Hi

How would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10
and when I click next

ASP.NET 2.0 - Enter Key - Default Submit Button
Hi,One of the most annoying things in developing web pages is handling the "Enter key" for form subm

how can i display php source code snippets ?
I am outputting some pho code .. and I want to display the source code so people can copy and paste

Do something every fifth time?
I'm trying to write a loop, but I want it to do something different after every fifth instance. Like

Multi Level Array Problem
hi all,

For example I have array like below:

$temp = array(array('north america', 'us'

how to read and write into a word document using php...?
hi,
I need,reading and writting into a word document using php.




Thank u inadva

Create multiple (n) arrays
Hi there,

I have the following need:

I have 2 arrays (coming from a databases)

styling a RadioButtonList
HiI need to have a radio button and close to it, its lable, then a space then another set of those.

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