php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14393 Function calling filename built-in access
Submitted: 2001-12-09 10:35 UTC Modified: 2011-01-01 00:05 UTC
From: foobardotcom at poczta dot onet dot pl Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.1.0 OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: foobardotcom at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2001-12-09 10:35 UTC] foobardotcom at poczta dot onet dot 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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-08 11:11 UTC] webmail at webcodefocus dot com
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()]"
 [2011-01-01 00:05 UTC] jani@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: Scripting Engine problem
 [2011-01-01 00:05 UTC] jani@php.net
Incomprehensible request.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC