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

Renaming array keys
The issue: renaming array keys inside a foreach loop.

I'm trying to build a pie chart image w

VAT
how should I deal with VAT?

if I have a product that costs £5.00 and VAT @ 17.5% (£0.87

str_replace help
Hey there,

I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean

checkbox update
I am having a brain fart right now and i cant remember how to do this. if anyone could help that wou

HTML Email rec'd as Source Code
The code does create and send the email successfully. However, the message shows as html code and n

Newb advice
Hi all,

I'm a flash front end designer and I've taken on a project that needs some back end p

Getting PHP to ammended the selected in option field
Hey Guys

thanks for everyones help so far. This site and its users are oozing awesomness.

PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator

fopen() security
As i understood the usage of fopen() for it to function correctly the Dir you write to has to be rw

"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql

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