Unset A Class


Jun 13, 2005

I've got sites which are pretty modular and full of classes which are pieced together to create a "whole".

I've just added my hit counter to a WordPress blog and they're fighting over a class named "init"

Once my stats are run I can drop the class definition - but I can't work out how to do this. I've crawled through http://www.php.net/manual/en/ref.classobj.php but there doesn't seem to an undeclare or unset for class definitions. Can anyone elighten me?

The only solution I can find is to rewrite one of my scripts so that the class has a unique name but for now I'd rather leave them as is.

View 2 Replies


ADVERTISEMENT

Is It Possible For An Instance Of A Class To Unset Itself?

Is it possible for an instance of a class to unset itself?

can I do "unset($this)" or "unset(&$this)"

View 7 Replies

Oop - Unset All Parent Classes When Only A Child Class?

I have extended a class that is part of a large library. I instantiate the extended class. Later, I'd like to unset() the extended class and all the related classes that have been instantiated in library. How do I do this when I only know the extended class that I have instantiated.

View 1 Replies

Sessions Unset When Not Asked To Be Unset By Another Script Not Even Called

I have 3 php's

home.php
createStep1.php
createCheckPass.php
createStep2.php
home.php unsets some $_SESSION variables if they still exist from previous pages:
Code: [Select]if(!empty($_SESSION['ame']))
{
unset($_SESSION['ame']);
[Code]....

createCheckPass.php gets some posted information from createStep1.php, checks everything is ok and if so sets the above session variables createStep2.php gets the session data set by createCheckPass.php and then gets to work with the user inputting data into the db. The odd problem If createCheckPass.php finds any problems with the posted data it redirects the user back to createStep1.php with the sessions set, createStep1.php then displays the errors with the info set in the sessions to the user and everything works ok.

If however the user sends the form from createStep1.php with no problems and the createCheckPass.php passes the user onto createStep2.php, something strange happens... The sessions set by the createCheckPass.php are only ever unset at the home.php, yet somehow createStep2.php loses the sessions and therefore doesn't run. What is even stranger is if i comment out the unsetting of the sessions from the home.php, everything works fine and none of the sessions are lost. Really really odd Summary: createStep2.php is reading the unset session lines of code from home.php when never asked to.

View 3 Replies

Strange Session / When The Session Is Unset It Seems To Unset It From The Very Beginning Of The Script So That The Message Doesn't Display?

I'm having a strange issue with sessions in PHP. Basically, when a user submits a contact form, the processing script sets a session on completion ( $_SESSION['action']='sent'; ). The user is then sent back to the page they sent the form from and a message is displayed using the following code:

$action = $_SESSION['action'];
if ( $action == 'sent' )
{
echo '<p>Thank you for contacting us, we will be in touch with you ASAP.</p>';
unset($_SESSION['action']);
}

The session is unset so if they refresh the page or navigate away and come back the message won't be displaying any more.

Basically the problem is that when the session is unset it seems to unset it from the very beginning of the script so that the message doesn't display. The if statement is obviously running as the session is being unset, but the message isn't displaying.

I've used this exact same script many times before and it works absolutely perfectly on other sites (on the same server, with all the same settings).

View 5 Replies

Unset The Session Variable For A Particular Index As The Vay Whole Session Is Made Unset?

is it correct to unset the session variable for a particular index as the vay whole session is made unset in PHP?

I know this works: unset($_SESSION['bannersize'])

But does this works ? : unset($_SESSION['bannersize'][3])

or is there any other way to unset any particular desired index of the session and then again rearrange the values inside it to remove the empty index..?

View 2 Replies

Class Method Returns Object From A Class That Uses Methods/properties From The Higher Class?

I'm trying to achieve a simple behavior in my code, but i can't think of a decent way of doing it. Take a look at what i'm trying to do:

$db = new Database('mydb');
$db->createTable('sample');
$myTable = $db->getTable('test');
$myTable->insert($data);
[code]...

View 2 Replies

Making Validation Class - Normal Class - Abstract Class - Interface - Polymorphism

im am making a php validation class with sub classes that extend it, eg, mobile, suburb, credit_card, ect so, the idea is you can call

$validation = new Validation('mobile');
$valid = $validation->validate($number);
$validation->type('suburb');
$valid2 = $validation->validate($suburb);

now my idea for doing this is having

[Code].......

View 1 Replies

If() And Unset()

I'm using 'if' to check if a form has been submitted and if it has Insert stuff into the dB..... but if the page is reloaded it Inserts again! I can't seem to drop the $Submit at all. I've tried 'unset' but no joy, can anyone point me in the right direction? PHP Code:

View 8 Replies

Unset

Hey i have a loop like so,

foreach($users as $user)
{
foreach($syncWebUsers as $sync)
{
//user already synched
if($sync['crmid'] == $user[$crmid])
{
echo "User Already
Synched".$user[$crmid];
unset($user);
}
}
}

View 2 Replies

Unset Bug

I use Cpanel, and allowed Web Host Manager to upgrade to the latest Apache and PHP 4.3.3. I regretted this greatly, because subsequently the Unset command would always cause a parse error. My test site was using PHPBB. I've read that the @ operator causes parse errors with Unset, but it doesn't use the 'at' sign at all. The same command fails with sample code from the PHP documentation. My only solution was downgrading PHP.

View 1 Replies

How Much Can Unset Do?

Given a bunch of mixes variables, I'm in a situation where I can't know what type they are.

Can I use unset to kill an object? unset($object);

Can I use unset to kill a pointer to an open file? unset($fp);

Can I use unset to kill a pointer to a database return?

unset($mySqlResult);

Because of heavy masking in my objects, I often don't know what type of variable I've got. In particular, I don't if the resource I've got is a file pointer or a database pointer, all I know is that is fetched data from some datastore. So, given the uncertainty, is unset a reasonable way to kill these variables?

View 7 Replies

Unset ($this)

In a nutshell do you think is best pratice to unset $this at the end of a class (PHP4)?

For instance a method like this: ....

View 2 Replies

Unset

I am trying to build a page with two seperate forms. If the user fills in one form but not the other, I only want that form to be submitted once. Currently, if the user fills in one form, then fills in the second form and submits, BOTH forms are submitted, causing a duplicate message to be sent.

Any ideas on how I can circumvent this?

View 1 Replies

Unset()

If the user enters a bad information i want all the others values to be unset but this does not work. how can i do it?

<?php
foreach($_POST as $k=>$v){
unset($k);
}

?>

View 1 Replies

Access Property Of Class From Within Class Instantiated In Original Class?

I'm not certain how to explain this with the correct terms so maybe an example is the best method...

[Code...]

My problem is i'm not certain how to access the properties of the MasterClass from within the EventProcess->DoSomething() method? I would need to access, perform operations on and update the properties. The a,b,c properties will be quite large arrays and the DoSomething() method would be called many times during the execuction of the script.

View 1 Replies

Calling Static Method From Class B (which Extends Class A) Of Class A?

There was an interesting question in a practice test that I did not understand the answer to. What is the output of the following code:

<?php
class Foo {
public $name = 'Andrew';

[code]....

Initially, I thought this was produce an error because static methods can not reference $this (atleast in PHP5). I tested this myself and it actually outputs John. I added Foo::getName(); at the end of the script and did get the error I was expecting. So, what changes when you call a static method from within a class that extends the class you're calling from?

View 5 Replies

Unset Problem

I'm trying to write a script that reads filenames from a file and opens them. The master file that contains all these filenames divides the filenames with a |. I am having a problem when blank spaces occur (filename||blah|whatever < the || is a space) because the script attempts to open the blank file. I tried to remove the blank bits from the array when it is being read using the unset function. But the script is still trying to open the blank file. PHP Code:

// Get rid of empty places in the file list array
$x=0;
while ($x < count($image_listing)) {
if ($image_listing[$x] == "") {
unset($image_listing[$x]);
}
$x++;
}

View 6 Replies

Unset() Not Unsetting

Don't know what's going wrong with my code but for some reason I can't seem to remove files from the server i.e. .pdf's, .doc's, etc etc.

I'm not sure if there is a way to display an error message from unset() or die(ERROR MESSAGE HERE);

but I have done the following code, maybe someone can shed some light on where i have gone wrong:

$row3['document_ul'] = "documents/14499154b8803c_sample.pdf"
(this is a sample of what $row3[''] holds) The location of the file is already added so I know that is correct. PHP Code:

View 2 Replies

Unset Array

I've created the following code:

<?php
session_start();
?>
......

View 1 Replies

Unset() - Value Of The Array Zero

I have a for loop, in it an array is assigned, then used in the loop, and on the bottom of the loop I have the array being unset() with the intent of the array starting at 0 in the next cycle of the loop.

Doesn't seem to be working. The initial value of the array zero element seems to be sticking.

View 4 Replies

Unset() Is Not Unsetting!

I have a cart, setup as an associative array (itemid=>qty). When the
cart is displayed, the quantity field is an input box and the value can
be changed to add/remove an item:
echo '<input type = "text" name = "'.$itemid.'" value = "'.$qty.'" size
= "3">'

when the "Save changes" button on the page that displays thecart is
pressed, a hidden field called "save" is set and the form is submitted.

session_start();
if(isset($_POST['save']))
{
foreach ($_SESSION['cart'] as $itemid => $qty)
{
$new_qty = $_POST[$optionid]; // I used (int)
$_POST[$optionid], didn't help
if($new_qty == 0) // Removing item?
{
// Search the cart for items dependent on the item being removed
if (!($result = check_required($optionid,
$_SESSION['builderid']))) { // this function returns FALSE
unset($_SESSION['cart'][$optionid]);
unset($_SESSION['optionid']);
}
.....
}
}
This things seems to go into an infinite loop. It unsets, say item 4000,
then goes back and tries to remove it again, and again. I used
error_log() function to see what is going on and it seems that the value
of the cart['itemid'] is unset but for some reason it is still there;
that particualr item keeps showing up.

View 2 Replies

How To Unset (clear) A Var?

Code:
$DatabaseActions = new Database();
// some code
$DatabaseActions="";

What is that the best way to unset it (i doubt it) I want it to be NULL - "dissapear"

View 1 Replies

Unset Function?

I was wondering how I would go about accomplishing this:

function some_func() {
print 'hey'
}

unset(some_func());

Is this possible, or is there a more professional way to unset a function instead of doing:

function some_func() {
}

View 1 Replies

Unset Won't Work?

Why won't $new_var be unset in the following function?
Am i missing out something?

Greetings Frizzle.

*************************************

function DoThis( $state, $fst = 1, $scnd = 2)
{
if( $state === 0 )
{
global $new_var;
unset($new_var);
}
else
{
global $new_var;
return $new_var = $fst + $scnd;
};
};

echo DoThis( 1, 4, 8);
echo DoThis( 0 );
echo 'new_var= '.$new_var;

View 1 Replies

Unset() Or Putenv()

Attempts to use both to "unset" or "clear" the value of PHP_AUTH_USER or PHP_AUTH_PW do not seem to function. Is this possible? To clear these values, other than by closing out the browser?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved