View previous topic :: View next topic |
Author |
Message |
eyn -
Joined: 11 Sep 2004 Posts: 32 Location: Canada
|
Posted: Sun Jan 02, 2005 8:43 am Post subject: PHP newbie question |
|
|
Okay, I'm learning PHP using some eBook, I have some newbie question here. How to use a variable without getting the "undefined variable" notice from the compiler? For example, I have this line:
Code: | $movie_list=array_merge($movie_list, $movie); |
This is the first line where this variable is used. I want $movie_list to be an empty array, so I can append my $movie array to it each time the "foreach" loop goes in order form a movie list.
Am I suppose to declare an empty array such that $movie_list is not undefined when the compiler see it? How to declare an empty array?
Another newbie question, when you use print function such as below:
Code: | print "<SPAN class='headline'>My title</SPAN>"; |
I am forced to use ' instead of " for my headline css class, or else the compiler will give me error. Can I use "headline" instead of 'headline' without getting an error?
I hope my question make sense. I'm using PHP 4.3, testing on Abyss Web Server. Ah, also where is the php.ini file, and how do I use it? Thank you very much! |
|
Back to top |
|
 |
eyn -
Joined: 11 Sep 2004 Posts: 32 Location: Canada
|
Posted: Sun Jan 02, 2005 8:53 am Post subject: Well, guess what? |
|
|
Ha, I used the following code and it works!
Code: | $movie_list = array(); |
Oh well, I'm not really sure if this is the way you should do it, any idea?
I still have the other question I posted though. :p |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Jan 02, 2005 9:42 am Post subject: |
|
|
Im not too sure about your first question because im also still learning a few
things about PHP , here's an example as to why you have to use 'headline'
Since " is part of a print statement or a value set for a variable , you have
to escape the " in headline so PHP doesn't interpret it and show an error.
Example:
To tell PHP not to interpret the " in headline , just add a \ in the back of " so
just use \"headline\" for every quote and this will tell PHP not to interpret it. |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|