Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    Dear all, when I add the following code to my Joomla! template the output is 2!

    Any ideas?

    PHP Code:
    <?php
    $a 
    1;
    $b 2;

    function 
    Sum()
    {
        global 
    $a$b;

        
    $b $a $b;


    Sum();
    echo 
    $b;
    ?>
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk

  2.  

  3. #2
    Junior Member
    Join Date
    Nov 2009
    Posts
    5
    Member #
    20501
    Hey,


    Why don't you let the function print (echo) the variable itself? give it a try :ichatwink:

  4. #3
    Senior Member hagen's Avatar
    Join Date
    Aug 2005
    Posts
    408
    Member #
    10882
    Liked
    1 times
    Hiya, the issue is the scope outside the function so wont prove anything...

    Basically it seems that there is a bug in how global variables are handled in PHP...

    I fixed this problem by completely removing Joomla from the frontend and writing my own functions to generate the menu etc from the database...

    It's a solution I think I may use quite a lot of in future as I get all the organisation of the backend and facility to edit for my customers... with the freedom of PHP to do pretty much anything I want on the frontend... I also use the Joomla Apache rewrite module configuration which is great! :-)

    -Hagen
    Hagen Rose: hagen(at)jxwd(dot)co(dot)uk
    JX Web Development, Bournemouth, Dorset...JXWD.co.uk


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 01:04 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com