ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-Dev
php-Dev
Bug #14393 Updated: Function calling filename built-in access
by other posts by this author
Mar 8 2002 4:11PM messages near this date
[PHP-DEV] Bug #14393: Function calling filename built-in access | [PHP-DEV] Function names
ID:               14393
 Updated by:       webmail@[...].com
 Reported By:      foobardotcom@[...].pl
 Status:           Open
 Bug Type:         Feature/Change Request
 Operating System: all
 PHP Version:      4.1.0
 New Comment:

I would find something like this very useful:


file: ErrorList.php
-------------------
// ErrorList is an object
// Add is a method of ErrorList

function Add($message, $internal_message="")
{
    if (MASTER_DEBUG)
    {
        $function = func_get_caller();
        $tmp = "[$internal_message - $function]";
    }
    $this-Properties[] = "$message $tmp";
}


file: page.php
--------------
$ErrorList = new ErrorList;

...

function doSomething($value)
{
    if (is_null($value))
    {
        $ErrorList-> Add("value must be defined", __FILE__);
        return(false);
    }
}

..

$ErrorList-> ShowErrors();
// the above would print:
// "value must be defined [page.php - doSomething()]"


Previous Comments:
------------------------------------------------------------------------

[2001-12-09 10:35:33] foobardotcom@[...].pl

Create function, that will not constraint specifying __FILE__ who is
calling it.

  function vote($num) {
    global $votes;
    $votes[@func_get_caller()] += $num;
  }
  // 1.php: vote(5);
  // 2.php: vote(3);
  // all.php:
  include("1.php");
  include("2.php");
  print_r($votes);
  // should show array: array([1.php] =>  5, [2.php] => 3)
  // but without this function will show: array([0] =>  8)

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=14393&edit=1
Thread:



Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved