Unset A Class

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.



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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

Unset Array

I've created the following code:

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

View 1 Replies View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

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 View Related

Unset($_SESSION );

ive made a simple log out page using teh followin gto allows users to effectivly log otu e.g. remove records from the current session:

[php
<?php
unset($_SESSION );

?>
[/php]

is there any way to force logout after a certain time perios jsut incase someone doesnt log out?

View 3 Replies View Related

Unset() Function

i am trying to use the unset() function..but it's doesnt work. Code:

View 4 Replies View Related

Can't Unset $_GET

On my page, the user can display tables, created out of a database. So I
have several <a href> links to display the various tables. They all look
something like:

<a href=this_page.php?table=mytable1>the first table</a>
<a href=this_page.php?table=mytable2>the second table</a>
<a href=this_page.php?table=mytable3>the third table</a>

etc.

so the user clicks on a link and gets the table. now, when he goes back to the main page, and chooses another link, he always returns to the initial table, because the $table variable is still somehow "active"

I tried to unset the $_GET array at the start of the code of the main page, but still it does not work. When i do a print_r($_GET) before and after the unset, it shows me that in the $_GET array exists before the unset, but is away after the unset, so everything should be fine.

But why does the $table variable still remain in the system?

View 2 Replies View Related

Unset All Variables.

Is it possible to UnSet all variables that I have used in a script?

At the moment I have a cron job running a large script, another instance of this script needs to be run, but creating another job is too much trouble (the webhosts need to do it, and they keep messing it up). What i plan to do is add the second script to the end of the first (copy paste), but I would prefer it if all variables were unset just in case they interfere with the new part of the script.

If it is not possible, I will do them manually.

View 3 Replies View Related

Session Will Not Unset

I am fairly new to sessions. I have no trouble setting the session with:

$_SESSION['ucinetid']=$returned_ucinetid;

but I cannot unset it. Here is my 'logout' code:

session_start();
$ucinetid=$_SESSION['ucinetid'];
unset($_SESSION['ucinetid']);
session_destroy();

The $ucinetid variable still persists in subsequent scripts after the above code. This seems like it should work, no? What am I doing wrong?

View 2 Replies View Related







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