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.

ADVERTISEMENT

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

Feb 21, 2006

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?

Jul 6, 2011

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

Mar 23, 2011

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?

Oct 1, 2010

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?

Jun 17, 2010

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?

May 3, 2011

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

Jul 15, 2010

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()

Oct 30, 2002

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

Aug 10, 2006

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

Jul 17, 2005

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?

Jul 17, 2005

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)

Sep 9, 2006

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

May 24, 2005

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()

Jul 1, 2007

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?

Mar 19, 2010

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?

Feb 5, 2009

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

Nov 8, 2003

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

Jun 21, 2006

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

Dec 15, 2006

I've created the following code:

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

View 1 Replies View Related

Unset() - Value Of The Array Zero

Dec 5, 2002

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!

Jul 17, 2005

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?

Feb 20, 2003

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?

Jul 26, 2005

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?

Oct 4, 2005

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()

Mar 21, 2001

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 );

Jan 7, 2006

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

Jul 11, 2007

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

View 4 Replies View Related

Can't Unset $_GET

Jan 23, 2006

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.

May 23, 2005

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

Feb 9, 2006

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

When To Use Mysql_close And Unset()

Jul 17, 2005

Say for example, I have a php page similar to this....

if .....

if........

elseif......

else........

else ....

etc. where I have if/else statements nested in other ones.

Now I guess it's good practice to unset created variables within each if or else section as a) it's less work and b) secure (correct me if I'm wrong).

IF I'm using mysql_close, do I just need to open one connection at the top of the page and close it at the bottom, as I think I understand that php will only run queries within if/else which evaluate to true (and so all can use one connection), and then I can close the connection at the bottom of the page as php will go through all the code?

View 5 Replies View Related

Cookie And Unset.

Apr 24, 2006

I'm working on a logout function and if I use:

setcookie ("TestCookie", "", time() - 3600);

the logout doesn't work immediately unless I don't refresh the page. However if I use unset($_COOKIE['TestCookie']) it works fine without refresh. I've never saw use unset with $_COOKIE
and I'd like to know if I can use it without troubles. What do you think about?

View 5 Replies View Related

Session Id Unset Necessary

Oct 29, 2007

Can someone help me with my mailform? It uses a Flash mailform, together with php and session id.

First things first: in the index.php page it starts by setting the session:

Code: .....

View 2 Replies View Related

Should I Unset All The Variables I Use?

Jul 14, 2007

Should I unset all the variables I use?

Does it free up memory? Because I don't want to hog more than I need.

View 4 Replies View Related

Unset Variables

Aug 22, 2007

I have borrowed a function from PHP.net user notes. It cycles through alll the variables in a PHP program and prints them all. See below.


function getDefinedVars($varList, $excludeList)
{
$temp1 = array_values(array_diff(array_keys($varList), $excludeList));
$temp2 = array();
while (list($key, $value) = each($temp1)) {
global $$value;
$temp2[$value] = $$value;
}
return $temp2;
}


The excludeList variable is an array contraining several variables that are not listed such as _ENV and so forth.

I have been attempting to add to this so that it lists the variables and then right after, it unsets all of them. Eqauting in unsetting all the variables in an instance of PHP. I have tried to UNSET the global variable variable during the while loop, however with no success. No errors, however variables remain set.

function getDefinedVars($varList, $excludeList)
{
$temp1 = array_values(array_diff(array_keys($varList), $excludeList));
$temp2 = array();
while (list($key, $value) = each($temp1)) {
global $$value;
$temp2[$value] = $$value;

unset($GLOBALS[$$value]); //added unset here

}
return $temp2;
}

View 1 Replies View Related

Use Unset In __destruct()?

Feb 12, 2010

Is it a good practice to unset the variables that you used in a class? Or its an optional? If its a good practice what is the benefit of using the unset function?

View 1 Replies View Related

When To Use Unset Function

Jul 21, 2010

I'm new to php and got confused with when to use the unset function. Should I unset everything I set or only when I want to guarantee it gets unset now?

View 4 Replies View Related

Unset Open_basedir In Php.ini?

Oct 25, 2010

How to unset "open_basedir" in php.ini? And why would a wordpress site have this value set? Actually, I don't know what open_basedir is, but PHP WARNING is telling me to unset it...

Code: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set PHP is also giving me the warning ...

Code: open_basedir restriction in effect. I'm guessing unsetting open_basedir would fix both? I already have safe_mode disabled.

View 2 Replies View Related

Unset() - Only Key TO BE DELETED

Apr 8, 2010

I have a class and i have unset() within a function in it which throws Parse error unexpected T_UNSET.

Some code :
class foo
{
function abc()
{
unset($this->err['main']['sub']['TOBEDELETED']);
}
}

Where I want to unset only key TOBEDELETED.

View 2 Replies View Related

Unset Something By Clicking?

May 5, 2011

How do I go about unsetting something by clicking here?

[Code]...

As can be seen by the above I am trying to prevent abuse of the checkout process through having repeat hits on the checkout button (yes, I have already looked at implementing a captcha library and also something directly into the relevant library file to prevent checkout submissions unless something was ticked, etc. and they are both non-starters, unfortunately.The same was also true of using onSubmit controls). There is a good, valid, reason for this, mainly that the checkout process involves the generation of coupons on the server side that cannot be validated using the responsehandler process because Google Checkout will not acknowledge response acknowledgements.

The problem is that I am trying to find some way to implement an unset session snippet into a href link or similar. - Is there a function for this?- All I have been able to find so far is onClick, which seems, for many people, to cause more problems than it fixes, and which does not look like being able to help me with this particular problem.

View 6 Replies View Related

Unset $_SESSION Set Anyway?

Aug 4, 2007

On first pageview $_SESSION['allowed'] is set and  $_SESSION['disallowed'] is not. Why? This should only happen upon successfull log-in.

The code appears a bit long, but it's mostly just a log-in routine with various checks. When "allowed" is set, sections should be accessible from links in the menu. Code:

View 4 Replies View Related

Unset(); And Mysql_close();

Jun 14, 2007

Just wondering with unset(); Any real point for using unset(); unless for closing sessions. eg: unset($var); Will this take a load off the server? make speed better? jut wondering

With mysql_close(); Should i always use this to close the connection?

View 2 Replies View Related

Unset Whole Arrays

Jul 30, 2007

How do you unset whole arrays?

View 2 Replies View Related

Why Can't I Unset ($_POST)

May 5, 2007

I have a small script I wrote so people can vote on a page:

[code] .....

The issue I am having is that after the vote in inserted into the MySQL database I want the $_POST['submit'] to be unset or destroyed. This isn't working, because each time the page is reloaded it votes again and again.

View 13 Replies View Related

ADVERTISEMENT