php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51495 errors using variable variables as function arguments
Submitted: 2010-04-07 13:29 UTC Modified: 2012-04-13 21:01 UTC
From: marco at digitaldruid dot net Assigned:
Status: No Feedback Package: Variables related
PHP Version: 5.3.2 OS: linux/windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marco at digitaldruid dot net
New email:
PHP Version: OS:

 

 [2010-04-07 13:29 UTC] marco at digitaldruid dot net
Description:
------------
This problem happens with php 5.3, on 5.2 doesn't show up. Tried on linux (default php 5.3.2 packages from ubuntu 10.04 beta1) and windows (php 5.3.2 from easyphp).

Sometimes when I use a variable variable (name of the variable in curly brackets) as a function argument the script doesn't work as expected (execution time or memory limits are reached). This happens only in a few places in my script (most times the same function with same arguments works fine) and in those places if I replace the variable variables with normal variables it works normally.

Test script:
---------------
You can download my script from:

http://www.digitaldruid.net/download/php-residence_1.2.2.zip

Install it (mysql, postgresql or sqlite needed), once you get to "main menu" click on "configure and customize" --> "internet templates" --> "availability template", this page will stop loading when the affected function is reached.

This function is called (twice) in file php-residence/crea_modelli.php from line 215:

mostra_menu_date("./dati/selectperiodi$anno_modello.1.php","inizioperiodo$num1",${"inizioperiodo".$num1},"","",$id_utente,$tema);
echo " ".mex("al",$pag)." ";
mostra_menu_date("./dati/selectperiodi$anno_modello.1.php","fineperiodo$num1",${"fineperiodo".$num1},"","",$id_utente,$tema);

if I replace the above code with:

$inizioperiodo = ${"inizioperiodo".$num1};
$fineperiodo = ${"fineperiodo".$num1};
mostra_menu_date("./dati/selectperiodi$anno_modello.1.php","inizioperiodo$num1",$inizioperiodo,"","",$id_utente,$tema);
echo " ".mex("al",$pag)." ";
mostra_menu_date("./dati/selectperiodi$anno_modello.1.php","fineperiodo$num1",$fineperiodo,"","",$id_utente,$tema);

then the page loads fine. The function mostra_menu_date is located in file php-residence/includes/funzioni.php


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-08 09:46 UTC] marco at digitaldruid dot net
Please note that the arguments of function mostra_menu_date are NOT passed by reference, so I think there should be the same behaviour when using ${"inizioperiodo".$num1} or $inizioperiodo as an argument, if they contain the same value.
 [2010-05-12 16:16 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2010-05-12 16:16 UTC] mike@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2012-04-13 21:01 UTC] nikic@php.net
-Status: Feedback +Status: No Feedback
 [2012-04-13 21:01 UTC] nikic@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 10:01:26 2024 UTC