Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Accessing global variables

    When making my hacklets, I use Superglobals to tell me what variables are already available on that page by default so I don't reinvent the wheel.
    I have an issue in 156 with not being able to access what I could in 1.55, at the same point.

    Consider this code/try this (I used it in admin root).

    <?php //test_globals.php
    //define('DEBUG_AUTOLOAD',true);
    require('includes/application_top.php');
    echo 'BEFORE HTML<pre>$languages:'; print_r($languages);echo '</pre>';
    echo '<pre>$languages_array:';print_r($languages_array);echo '</pre>';
    echo '$languages_selected='.$languages_selected.'<br>';
    ?>
    <!doctype html>
    <html lang="en">
    <head>
    <title>Test Globals</title>
    <link rel="stylesheet" href="includes/stylesheet.css">
    <?php
    echo 'HEAD<pre>$languages:'; print_r($languages);echo '</pre>';
    echo '<pre>$languages_array:';print_r($languages_array);echo '</pre>';
    echo '$languages_selected='.$languages_selected.'<br>';
    ?>
    </head>
    <body onload="init()">
    <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
    Hello World
    <?php
    echo 'BODY<pre>$languages:'; print_r($languages);echo '</pre>';
    echo '<pre>$languages_array:'; print_r($languages_array);echo '</pre>';
    echo '$languages_selected='.$languages_selected.'<br>';
    ?>
    <div class="footer-area">
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    </div>
    </body>
    </html>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
    In 1.55 I get
    Before HTML (ie where you would normally do php stuff)
    $languages - available
    $languages_array - not set
    $languages_selected - not set

    HEAD:
    $languages - available
    $languages_array - not set
    $languages_selected - not set

    BODY:
    $languages - available
    $languages_array - available
    $languages_selected - available

    In 1.56 I get
    Before HTML:
    $languages - not set
    $languages_array - not set
    $languages_selected - not set

    HEAD:
    $languages - not set
    $languages_array - not set
    $languages_selected - not set

    BODY:
    $languages - available
    $languages_array - available
    $languages_selected - available

    The init_languages in 1.56 is a bit later than 1.5, I moved it earlier as much as possible (without breaking anything), but no change.

    So, if "things have been tightened up in 1.56", the question is, what is one supposed to do to get at these variables now?
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  2. #2
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Accessing global variables

    Using the super globals module will show you all you need

  3. #3
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,586
    Plugin Contributions
    30

    Default Re: Accessing global variables

    ...you didn't read my post twice....
    all three appear in the Superglobals list...but they are not all available as expected, WHEN they are expected.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 

Similar Threads

  1. Accessing public class variables in observer class
    By Dave224 in forum Code Collaboration
    Replies: 1
    Last Post: 20 Mar 2019, 07:11 PM
  2. v151 global $db;
    By makenoiz in forum General Questions
    Replies: 1
    Last Post: 18 Nov 2013, 01:49 PM
  3. Replies: 7
    Last Post: 18 Jun 2011, 07:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR