vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Version specific PHP code? (https://vborg.vbsupport.ru/showthread.php?t=107317)

Darth Cow 02-06-2006 07:12 PM

Version specific PHP code?
 
This code works just fine on localhost, running PHP 5.0.5. On the live site, running PHP 4.3.2, I get the following error:

Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /var/www/html/includes/class_bbcode.php(149) : eval()'d code on line 14

PHP Code:

// Deck tag plugin by Stephan Hoyer
// http://www.sccs.swarthmore.edu/users/08/hoyer/decktag/
//
// Title: Custom bbcode tag WYSIWYG fix
// This code is necessary so that when using the WYSIWYG editor to edit a post,
// vBulletin does not attempt to still show the HTML in the editor (as it does for
// simple [url] or [b] tags), but rather completely unparses the tags, returning
// the original tags around the contents of the post.
//
// vB3.5 hook location: bbcode_create

if (class_exists('vB_BbCodeParser_Wysiwyg') AND is_a($this'vB_BbCodeParser_Wysiwyg'))
{
    foreach (
$this->tag_list AS &$option)
    {
        foreach (
$option AS &$tag_name)
        {
            if (
$tag_name['callback'] == 'handle_external')
            {
                
$tag_name['callback'] = 'handle_wysiwyg_unparsable';
            }
        }
    }


Any ideas why this isn't working? Line 14 is the first foreach line, but it seems to be perfectly well formed. I'm pretty sure the live site and my localhost copy are the same in all other relevant respects.

Trigunflame 02-06-2006 07:20 PM

I dont believe php 4 supports references in a foreach construct, which you shouldnt being using regardless.

The nature of foreach is to use a copy of an array and go through it key by key, if you want to operate on references, it would be better to use a for construct

$keys = count($array);
for ($i=0;$i<=$keys;$i++)
{
$option = &$array[$i];
}

and so on

filburt1 02-06-2006 08:17 PM

There's nothing wrong with using foreach in most cases. Passing damn near everything by reference introduces more opportunities to screw up the orignal data bacause you accidently modify one of the elements.

Knowing specifically what line 14 is would help.

Trigunflame 02-06-2006 09:52 PM

I was basing my reply to him on the knowledge of php4 object model specifically having problems with references in foreach constructs.

But you are right, nothing wrong with using foreach in most cases (cept large arrays where copying an array might cause excessive memory usage).


All times are GMT. The time now is 08:50 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01133 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete