php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39535 function not passing global'ed variables
Submitted: 2006-11-16 16:01 UTC Modified: 2006-11-16 16:45 UTC
From: mark at divinedesigns dot ca Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.2.0 OS: linux
Private report: No CVE-ID: None
 [2006-11-16 16:01 UTC] mark at divinedesigns dot ca
Description:
------------
basically...
 function2 is in function1, function 2 has a globalized variable, but it is not passing out of funcion 1 or 2, if i set it to echo the variable, info comes out, but thats not very helpful...

Reproduce code:
---------------
i'll put it at taith.divinedesigns.ca/bug.php, taith.divinedesigns.ca/bug2.php

Expected result:
----------------
the +/- buttons are supposed to click on(javascript) and hide/show the contents underneath

Actual result:
--------------
no action, the $head variable doesnt pass from function #1 to function #2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-16 16:10 UTC] tony2001@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.


 [2006-11-16 16:14 UTC] mark at divinedesigns dot ca
my source code is shown on these two webpages
http://taith.divinedesigns.ca/bug.php
http://taith.divinedesigns.ca/bug2.php
 [2006-11-16 16:24 UTC] tony2001@php.net
Please provide SHORT but COMPLETE reproduce code. Some comments in the code with expected and actual results are appreciated.
 [2006-11-16 16:29 UTC] mark at divinedesigns dot ca
<?
function shownavs(){
 global $allnavs, $blocknavs, $head, $autokey;

 if(isset($allnavs)){
  $navsoutput .= '<table>';
  foreach($allnavs as $group => $i){
   $title = $group;
   foreach($i as $name => $link){
    if(isset($link)){
     $content .= '<br>'.$name; #this line usually has same issue, altered for bug report
    }
   }
   $text .= '<tr><td>'.set_collapse($title,$content,$group).'</td></tr>';
   unset($content);
  }
  $navsoutput .= $text.'</table>';
 }
 return $navsoutput;
}

function set_collapse($title,$text,$name){
 global $collapsenum, $css, $head;
 if(!isset($collapsenum)){
  $collapsenum = "1";
  $head .= '<script language="javascript">
var ie4 = false;
if(document.all){
 ie4 = true;
}

function getObject(id){
 if(ie4){
  return document.all[id];
 }else{
  return document.getElementById(id);
 }
}

function toggle(link, divId, Name){
 var lText = link.innerHTML;
 var d = getObject(divId);
 if(lText == \'+\'){
  link.innerHTML = \'-\';
  d.style.display = \'block\';
  document.cookie = Name + "=shown";
 }else{
  link.innerHTML = \'+\';
  d.style.display = \'none\';
  document.cookie = Name + "=hidden";
 }
}
</script>'; # it should be returning this outside of both the functions
 }
 return '<table cellspacing=0 width="50%" class=collapse>
 <tr class=collapsetitle>
  <td class=navtitle>[<a title="Show/Hide" class=toggle href="javascript: void(0);" onclick="toggle(this,\''.$key.'\',\''.$name.'\');">'.$h.'</a>]'.$title.'</td>
 </tr>
 <tr id="'.$key.'" class="'.$hidden.'">
  <td>'.$text.'</td>
 </tr>
</table>';
}

$allnavs[test]=test.php
$body = shownavs();
echo $head;
echo $body;
?>
 [2006-11-16 16:30 UTC] mark at divinedesigns dot ca
these functions work perfectly well when used on their own... but not so when combined...
 [2006-11-16 16:45 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Please use php-general@lists.php.net for such problems. Thank you.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 22 20:00:03 2025 UTC