I'm writing a simple linear linked list implementation in PHP. This is basically just for practice... part of a Project Euler problem. I'm not sure if I should be using unset() to help in garbage collection in order to avoid memory leaks. Should I include an unset() for head and temp in the destructor of LLL?
I understand that I'll use unset() to delete nodes when I want, but is unset() necessary for general clean up at any point?
Is the memory map freed once the script terminates even if you don't use unset()?
I saw this SO question, but I'm still a little unclear. Is the answer that you simply don't have to use unset() to avoid any sort of memory leaks associated with creating references?
I'm using PHP 5.. btw.
Unsetting references in PHPPHP references tutorial
Here is the code - I'm creating references when I create $temp and $this-head at certain points in the LLL class:
class Node
{
public $data;
public $next;
}
class LLL
{
// The first node
private $head;
public function __construct()
{
$this->head = NULL;
}
public function insertFirst($data)
{
if (!$this->head)
{
// Create the head
$this->head = new Node;
$temp =& $this->head;
$temp->data = $data;
$temp->next = NULL;
} else
{
// Add a node, and make it the new head.
$temp = new Node;
$temp->next = $this->head;
$temp->data = $data;
$this->head =& $temp;
}
}
public function showAll()
{
echo "The linear linked list:<br/> ";
if ($this->head)
{
$temp =& $this->head;
do
{
echo $temp->data . " ";
} while ($temp =& $temp->next);
} else
{
echo "is empty.";
}
echo "<br/>";
}
}
Thanks!
Hi,
I want to have an array of struct (an array of books with their specifications like publication, ISBN number, ...). in wsdl and php. I have searched a little and I have found files that uses Nusoap, However, I dont want to use NuSoap. Is there any solution? I would appreciate if you help me in writing the related wsdl, client and server (php) files.
Thank you so much.
Best, shadi.
Is there anyway invoke a PHP page / function when a record being inserted in to the mysql db table. We dont have control over the record insertion procedure.Is there some thing called trigger which can call a PHP script back ?
I'm not sure what to call this, so I'll give an example.
In PHP
1==2 || 2 returns 1 or true
In Ruby
1==2 || 2 returns 2 (The second statement if the first evaluates to false).
Is there any short way to implement similar thing in PHP?
I would like to name my css file mystyles.php. All content within will still be css. I'd like to then include this into my index.php page without using the standard HTML <link> tag. Any direction would be appreciated very much.
i have created a file with extention .php.so how should i run this file with netbeans.i have download the netbeans 6.8 with all bundle feature.i hav seen the php file can run with netbeans so i m asking.plz explain
I am sending login status = fail, back to my login page.Here is my code-
header("location:index.php?login=fail");
but that is sending through URL like-
http://localhost/303/index.php?login=fail
is there any way to pass value without showing in URL? And how to get this value on the second page?
I have the array variable say $value, and it has the below given array
[navigation] => navigationHistory Object
(
[path] => Array
(
[0] => Array
(
[page] => order_form.php
[mode] => NONSSL
[get] => Array
(
[id] => 31
)
)
)
)
how to echo/access the 'get' index of the given array in PHP syntax
I've got a simple login system using PHP sessions, but just recently it seems that if you visit pages not in a certain directory (/login/) you will always be flagged as not logged in, even when you are. It seems that my session data is being lost when I change directories (say, to /login/user/).
I don't think I've touched the code myself since the problem appeared, is there something my web host could have done to my PHP installation that would delete the session data, and is there a workaround?
I am trying to set a variable in an 'if' statement so that only when the 'if' statement is true, the variable will be set and will be able to be used somewhere else on the page.
Here's what I have tried:
if ($row[8] == 1) {
echo 'Message here';
ob_start();
include('F164.php');
$f164 = ob_get_clean();
}
as well as:
if ($row[8] == 1) {
echo 'Message here';
$f164 = include('F164.php');
}
Hi.
I want to retrieve all hashtags from a tweet using a PHP function.
I know someone asked a similar question here, but there is no hint how exactly to implement this in PHP. Since I'm not very familiar with regular expressions, don't know how to write a function that returns an array of all hashtags in a tweet.
So how do I do this, using the following regular expression:
#\S*\w
Hello,
How can I read from mysql and write the same in http output stream.
So its like if send a request http://www.xyz.com/download/A
it should return me data for A from mysql through php.
The data is plain text.
Thanks
PS: I am new to php.
Hello,
I'm using lighttpd as webserver for php application server. The avg. load on this server is about 2-3. MySQL database is separated to another server (it's load ~0.4). How could I scale php application server?
Thank you.
I am working on an example from a php book and am getting an error on line 8 with this code
<?php
$agent = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$agent"));
{
$result = "You are using Microsoft Internet Explorer";
}
else if (preg_match("/Mozilla/i", "$agent"));
{
$result = "You are using Mozilla firefox";
}
else {$result = "you are using $agent"; }
echo $result;
?>
Is this iteration the best?
(Pi^2)/12 = 1 - 1/4 + 1/9 - 1/16 + 1/25 etc.
-For converging faster?
If not please answer with the iteration -preferably in the form above (an example) -not a splat of algebra ...
I'm doing this to find Pi to 1,000,000,000 places online.
http://www.zombiewrath.com/superpi.php
or my 10,000 one:
http://www.zombiewrath.com/pi.php
Hi,
I have been working with C# so this is quite strange for me:
while($variable=mysql_fetch_assoc)
I have not been able to look up in PHP manual how it works. I guess that in each loop it advances to next element of assoc.array. But what is this generally called in PHP? I am just not used to see '=' in loop condition.
I am working on a live remote php project in eclipse. ie, I just connect the the project using RSE edit the files and save.
I have recently setup subeclipse and am wondering if there is an way to add my php files to a subversion project while still working on the live project? Or maybe there is a better way to do this and get the same result.
Hi,
I have a simple Ruby on rails application that I want to integrate with an existing php website. I only want that users who's been authenticated by the php application would have access to my Ruby on Rails application (it should appear to the user as the same website, in the same domain, though it can be a different sub-domain if I chose to)
What's the best way to do that?
Thanks for the help,
Li
I have php class(simple example):
<?php class test{
public function __construct() {
//some code
}
public function __destruct() {
//some code
}
public function echo1 {
//some code
return 1;
}
public function echo2 {
//some code
return 2;
}
}
How could I return results of this two functions echo1 and echo2 in class in one row don't creating two new objects for each function?
I'm using embed tag in PHP like this:
echo "<embed src='images/meccaAdhan.mp3' name='guitar' id='BGS_ID' autostart='true' loop='false' width='2' height='0'></embed>";
I need to add this code before images:
templates/<?php echo $this->template ?>
Please guide me how to solved it.
How can this
<?php
assert( 1.0 < 2.0 );
?>
result in
Warning: assert() [function.assert]: Assertion failed in C:\Program Files (x86)\wamp\www\test.php on line 2
Edit: depending on the file I put this code in, 1.0 < 2.0 evaluates to false or true.
I just finished coding a complex job assignment application where a lot of the work was done using priority queues. When I deployed, however, I discovered the web server ran PHP 5.2.
Has there been an implementation for PHP<5.3 that can server as a drop-in replacement for SPLPriorityQueue?
I have an output from a page- Uploader.php. Now i go to some oter page and when havea button on that page to reroute to this page- Uploader.php, i want the iutput of the page to be seen rather than reprocessig the page.