I'm working my way through learning php, it looks a lot like perl and
then again it doesn't.
I'm confused about scope of variables and public. The PHP manual
sometimes leaves me confused. I have some very simple questions.
####
I'm used to declaring global variables with either "our" or "my".
It looks like in php, it's just.
$my_variable='foo';
function my_function(){
$my_variable; // not defined;
public $my_variable;
// $my_variable now = 'foo'; is that right?
}
Is that the only way? Do I have that wrong?
####
Now, I'm confused about the use of public in a class.
class Foo{
$x='X';
public $y='Y';
}
How is the public declaration different? Is it the same for
instance, and unavailable as a class?
####
I'm used to putting all my objects in separate file. What's the naming
convention for doing this in PHP.
Can I have methods of a class defined outside the class brackets? Can
I do something like this:
class Bar{
$some_method=someMethod();
}
function someMethod(){
....
}
####
Is this:
$some_array=('one','two');
$some_array[]='three';
The same as push?
Is there an easy way to add to the top of the array than the bottom?
What about shifting an element of the array?
And if you have mixed:
my_array=('one','3'=>'three','2'=>'two');
How is that ordered?
Jeff