vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Passing by reference (https://vborg.vbsupport.ru/showthread.php?t=61797)

filburt1 02-22-2004 07:59 PM

Passing by reference
 
http://www.php.net/manual/en/languag...nces.unset.php

So, what if I want to destroy the variable that was passed to a function?
PHP Code:

function executeFilterAction(&$message$filter)
    {
        
$subject htmlspecialchars_uni($message['subject']);
        
        switch (
$filter['tofolderid'])
        {
            case 
VBMS_FILTER_TOFOLDERID_DELETE:
                
debugecho("Message "$subject" will be deleted");
                unset(
$message);
                break;
                
            case 
VBMS_FILTER_TOFOLDERID_MARKASREAD:
                
debugecho("Message "$subject" will be marked as read");
                
$message['readflag'] = true;
                break;
                
            default:
                
debugecho("Message "$subject" will be moved to folderid " .
                        
$filter['tofolderid']);
                
$message['folderid'] = $filter['tofolderid'];
                break;
        }
        
        return 
false;
    } 

Note that VBMS_FILTER_TOFOLDER_DELETE case and what it does.

filburt1 02-24-2004 12:26 AM

Nobody has an idea on this...

Velocd 02-24-2004 04:07 PM

PHP Code:

    $a 5;
    
$b =& $a;

    echo 
$a;
    echo 
'<br />';
    echo 
$b;

    unset(
$a);

    echo 
$a;
    echo 
'<br />';
    echo 
$b

Returns:

Code:

5
5
5

With $a eliminated.

PHP Code:

    $a 5;
    
$b =& $a;

    echo 
$a;
    echo 
'<br />';
    echo 
$b;

    
$a '';

    echo 
$a;
    echo 
'<br />';
    echo 
$b

Returns:

Code:

5
5

Some kind of PHP quirk perhaps.

filburt1 02-24-2004 04:16 PM

Note that it is in a function.

Velocd 02-24-2004 04:38 PM

Quote:

Originally Posted by filburt1
Note that it is in a function.

Yes, I noted. It isn't possible then, since any variable outside of a function is out of scope unless it's a global.

Maybe calling another function and unsetting the variable, or if it was part of a class unset its member variable of the object.

[high]* Velocd shrugs[/high]


All times are GMT. The time now is 01:22 PM.

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.01104 seconds
  • Memory Usage 1,736KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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