Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Undefining a variable

compuchipcompuchip Member Posts: 273
Is it possible to "undefine" a variable. So eg. I could say:

[code]
function check() {
if ($a) {
print " $A DELETED
";
[red]undefine[/red] $a;
}
else {
print " $A NOT DEFINED
";
}
}

$a = "Something";
global $a;
check();
check();
[/code]

Comments

  • mac_doggiemac_doggie Member Posts: 488
    Try:
    [code]
    $a = false;
    [/code]

    : Is it possible to "undefine" a variable. So eg. I could say:
    :
    : [code]
    : function check() {
    : if ($a) {
    : print " $A DELETED
    ";
    : [red]undefine[/red] $a;
    : }
    : else {
    : print " $A NOT DEFINED
    ";
    : }
    : }
    :
    : $a = "Something";
    : global $a;
    : check();
    : check();
    : [/code]
    :

    ;-)
    -mac-
    mailto:[email protected]
    the Netherlands...


  • compuchipcompuchip Member Posts: 273
    Maybe I didn't describe the problem well.
    I have a table on page 1 with 5 rows. On the end of each row there are three choices, let's say A, B and C.
    Now what I wanted to do, is store them in an array, so:
    [code]
    # Put the textfields in $choices[0..4]
    session_register("choices");
    gotoPage(2);
    [/code]

    On page 2, I want to process the array and when I'm done, delete it or unregister it. Something like
    [code]
    # process the $choices[0]
    # process the $choices[1]
    # process the $choices[2]
    # process the $choices[3]
    # process the $choices[4]
    session_unregister("choices");
    [/code]

    Do you get the point?

    : Try:
    : [code]
    : $a = false;
    : [/code]
    :
    : : Is it possible to "undefine" a variable. So eg. I could say:
    : :
    : : [code]
    : : function check() {
    : : if ($a) {
    : : print " $A DELETED
    ";
    : : [red]undefine[/red] $a;
    : : }
    : : else {
    : : print " $A NOT DEFINED
    ";
    : : }
    : : }
    : :
    : : $a = "Something";
    : : global $a;
    : : check();
    : : check();
    : : [/code]
    : :
    :
    : ;-)
    : -mac-
    : mailto:[email protected]
    : the Netherlands...
    :
    :
    :

  • iDaZeiDaZe Member Posts: 464
    unset($a)
  • compuchipcompuchip Member Posts: 273
    Thanks
  • Shawn CarterShawn Carter Member Posts: 0

    _______ / http://forcoder.org / free ebooks and video tutorials about { C++ Objective-C JavaScript C# Perl Delphi Assembly Visual Basic .NET Go Visual Basic Java Swift C Ruby R PHP Scratch PL/SQL MATLAB Python Lisp Clojure Scala SAS F# ML Dart Logo Alice Hack Scheme LabVIEW Kotlin Rust COBOL Ada Crystal Lua Awk Julia VBScript Fortran Transact-SQL ABAP FoxPro Prolog Erlang D Apex Bash } ___________

Sign In or Register to comment.