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.
View 2 Replies (Posted: 06-13-2005, 01:14 AM)
Sponsored Links:
Related Forum Messages:
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.
Posted: March 23, 2011, 01:30:19 PM
View 3 Replies!
View Related
Unset Isset $_POST - Unset A Submit Button?
s it possible to unset a submit button? <?PHP if(isset($_POST['Submit'])) { $date = $_POST['date']; [code].... What I'm wondering is if it's possible to unset after submitting in the event of condition x. Should this not in turn echo out the form as it has been unset?
Posted: October 19, 2010, 10:34:04 AM
View 6 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).
Posted: Oct 1 10 at 9:40
View 5 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:
Posted: October 30th, 2002, 11:13 AM
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); } } }
Posted: August 10th, 2006 04:15 PM
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.
Posted: July 17th, 2005 02:14 AM
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?
Posted: July 17th, 2005 04:16 AM
View 7 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); } ?>
Posted: July 01, 2007, 04:16:47 PM
View 1 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?
Posted: 12:47 pm on May 24, 2005
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.
Posted: Mar 19 10 at 17:27
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?
Posted: Feb 5 09 at 15:27
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++; }
Posted: November 8th, 2003, 03:44 AM
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:
Posted: June 21st, 2006, 04:54 AM
View 2 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.
Posted: December 5th, 2002, 10:56 PM
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.
Posted: July 17th, 2005 04:20 AM
View 2 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() { }
Posted: 6:24 pm on July 26, 2005
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;
Posted: October 4th, 2005 11:35 AM
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?
Posted: March 21st, 2001, 12:21 PM
View 2 Replies!
View Related
Unset $_SESSION Set Anyway?
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:
Posted: August 04, 2007, 11:11:10 AM
View 4 Replies!
View Related
Unset(); And Mysql_close();
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?
Posted: June 14, 2007, 10:04:08 PM
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?
Posted: 01-07-2006, 07:56 PM
View 3 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?
Posted: January 23rd, 2006 07:35 PM
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.
Posted: 05-23-2005, 03:28 PM
View 3 Replies!
View Related
Why Can't I Unset ($_POST)
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.
Posted: May 05, 2007, 11:06:03 PM
View 13 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?
Posted: 02-09-2006, 06:04 PM
View 2 Replies!
View Related
When To Use Mysql_close And Unset()
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?
Posted: July 17th, 2005 11:36 AM
View 5 Replies!
View Related
Cookie And Unset.
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?
Posted: 04-24-2006, 06:00 AM
View 5 Replies!
View Related
What Could Cause A Cookie To Become Unset?
This is a unique problem in which I'm struggling on. Earlier I thought the problem was global variables, but it is not the problem. It is the cookies which is causing me the problem. So here's the story. I had an entire site working perfectly on my test server in my basement (php 5.2) I signed up for VPS access. Installed this entire site on my new VPS server (php 4.3.9) I have the exact same code running on both servers, but it works on my test server in the basement, but not on the VPS server. For some reason one of my cookie variables is becoming unset. I use the setcookie function to set the cookie and $_COOKIE['name'] to get the value out. I ripped out all of the cookie processing code on the VPS server and put it in separate source files with no other code from the site and it worked perfectly fine. The cookie value was retained as expected. Where should I look to fins an error like this? Where would you look first? This is driving me crazy and there is really no way I can post the code of my entire site here. I thought about ripping out the cookie related code and posting it here, but when I did, it worked.
Posted: October 12, 2007, 05:08:16 PM
View 14 Replies!
View Related
|