Array becomes unset by itself?


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I have a bit of experience with PHP but not extensive. It seems I cannot store any items to the array $details.

Did you know?Explore Trending and Topic pages for more stories like this.
The class:

class Newsletter {
public $details = array();

function Newsletter($id) {
$details['id'] = $id;
echo "From same function: " . $details['id'];

$this->Load();
}

function Load() {
echo "From sibling function: " . $details['id'];
}
}

The call from the webpage:

$x = new Newsletter(123);
//output
From same function: 123
From sibling function:

Is there a special way to interact with the array so that it sticks for use with other functions?

Thanks
No comments posted yet

Your Answer:

Login to answer
217 Like 20 Dislike
Previous forums Next forums
Other forums

Port scanner problem
Hai
recently i developed one app through which u can check the opened and closed ports under an

Users and Groups with PHP Classes
Hi,

I have setup what I hope to be a good working User class. Now I want to introduce group m

pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n

I think i'm using the syntax incorrectly
Hi Everyone!

I'm new to this forum and a newbie with PHP - I'm glad I found this site - I hop

Syntax Help
I'm trying to make a form that edits a php file which contains config settings. I'm using strings t

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

Echo-ing MySQL content and Keep Formatting?
I have data in my MySQL such as:

QuoteBlah blah

Blah blah

etc
but when i ech

php + mysql count consecutive data
I have a database of values and I want to work out how to display them if the values match a consecu

Why do I get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/a5488351/public_html/b

Frustrated php Newbie
First off, I am pretty much a PHP nub. I can read and understand the language (most of the time) so

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash