Lacrima Castle
HelpSearchMembersCalendar

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> First PHP lesson: Text
Rosetta
post Dec 30 2005, 06:30 AM
Post #1


Admiral
*****

Group: Flunkies
Posts: 299
Joined: 23-December 05
From: Space Dreadnought "Nonna"
Member No.: 3



Hello, everyone. Sorry i'm late. We're going to start the first lesson with the most basic of basic; outputting text. Before that however, I'll have to tell you some things on how PHP works. PHP code is executed on the server's side, so that means that you can't view the PHP code when you click on "View Source", as it only shows the outputted information from the PHP code.

Open up your favourite text editor, and follow along, please.

Now, to begin any PHP page, we must start with this:

CODE
<?php


That tells the server that there is going to be some PHP code being executed. Again, this MUST be in the PHP file for it to work!

Now that we've got that done, we'll learn how to CLOSE the PHP code.

Make a few blank lines, and then at the last line, type this in:

CODE
?>


That tells the server that the PHP execution will stop at that point. So when using PHP, all the PHP code MUST be within these:

CODE
<?php
?>


Now, to output the text, we will use a simple command named: echo.

In between the start and close PHP things, type this in:

CODE
echo "";


To output the text, put in the text you wanty to output in between the "s.
The purpose of the ; at the end is significant. When programming in PHP, you have to end almost every 'command' with this, since it in a way, tells the server that the 'command' is finished, and to move on to the next one.


Now, for your homework... I want all those who want to participate in this, write a PHP file that outputs one of your favourite quotes or phrases. To save as a PHP file, simply choose Save as type: All Files, and file.php.

Send to me via AIM if possible.

Good luck, and I look forward to seeing your homework!


~~~
Au.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 06:34 AM
Post #2


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



do i have to do another one, miss Kohaku?

XD

well, i think i still have one here. the one i did XD


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
blues
post Dec 30 2005, 06:43 AM
Post #3


It could be better
********

Group: Magi
Posts: 701
Joined: 25-December 05
Member No.: 17



QUOTE (Kohaku @ Dec 30 2005, 06:30 AM)
Hello, everyone. Sorry i'm late. We're going to start the first lesson with the most basic of basic; outputting text. Before that however, I'll have to tell you some things on how PHP works. PHP code is executed on the server's side, so that means that you can't view the PHP code when you click on "View Source", as it only shows the outputted information from the PHP code.

Open up your favourite text editor, and follow along, please.

Now, to begin any PHP page, we must start with this:

CODE
<?php


That tells the server that there is going to be some PHP code being executed. Again, this MUST be in the PHP file for it to work!

Now that we've got that done, we'll learn how to CLOSE the PHP code.

Make a few blank lines, and then at the last line, type this in:

CODE
?>


That tells the server that the PHP execution will stop at that point. So when using PHP, all the PHP code MUST be within these:

CODE
<?php
?>


Now, to output the text, we will use a simple command named: echo.

In between the start and close PHP things, type this in:

CODE
echo "";


To output the text, put in the text you wanty to output in between the "s.
The purpose of the ; at the end is significant. When programming in PHP, you have to end almost every 'command' with this, since it in a way, tells the server that the 'command' is finished, and to move on to the next one.


Now, for your homework... I want all those who want to participate in this, write a PHP file that outputs one of your favourite quotes or phrases. To save as a PHP file, simply choose Save as type: All Files, and file.php.

Send to me via AIM if possible.

Good luck, and I look forward to seeing your homework!

miss Kohaku is notepad a text editor? Would you like me to bring an apple next time?


~~~
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 06:51 AM
Post #4


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



notepad is useable, she said. i used notepad myself :\


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Dr Strum
post Dec 30 2005, 06:57 AM
Post #5


Can Lead the Nation with a Microphone
***************

Group: Angels
Posts: 5425
Joined: 23-December 05
From: Seattle
Member No.: 1



It should be noted that there are other text output functions, such as print, printf, and the file printing functions when using the proper output methods.


~~~
Писатель всегда будет в оппозиции к политике, пока сама политика будет в оппозиции к культуре.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 07:02 AM
Post #6


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



hmm....thanks, Sturm. i'll keep that in mind.


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Rosetta
post Dec 30 2005, 07:50 AM
Post #7


Admiral
*****

Group: Flunkies
Posts: 299
Joined: 23-December 05
From: Space Dreadnought "Nonna"
Member No.: 3



The print function isn't really used anymore in PHP.


~~~
Au.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 07:55 AM
Post #8


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



oh. that means i'll ignore it then :P


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Rosetta
post Dec 30 2005, 07:56 AM
Post #9


Admiral
*****

Group: Flunkies
Posts: 299
Joined: 23-December 05
From: Space Dreadnought "Nonna"
Member No.: 3



You don't have to ignore it.. i'm just saying that echo is more widely used than print now,


~~~
Au.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 08:01 AM
Post #10


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



okay XD

so, what makes print different from echo?


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Rosetta
post Dec 30 2005, 08:02 AM
Post #11


Admiral
*****

Group: Flunkies
Posts: 299
Joined: 23-December 05
From: Space Dreadnought "Nonna"
Member No.: 3



They're pretty much the same actually. Print is more of a multi-language thing, so when PHP eventually got it's own (echo), more people switched to that.


~~~
Au.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 08:09 AM
Post #12


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



aaaaaaaah. no wonder XD


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Dr Strum
post Dec 30 2005, 09:00 AM
Post #13


Can Lead the Nation with a Microphone
***************

Group: Angels
Posts: 5425
Joined: 23-December 05
From: Seattle
Member No.: 1



printf() > All
No matter what.


~~~
Писатель всегда будет в оппозиции к политике, пока сама политика будет в оппозиции к культуре.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Swiyth
post Dec 30 2005, 09:01 AM
Post #14


Vlayghn el Deistra
*****

Group: Arcs
Posts: 223
Joined: 23-December 05
Member No.: 2



well, what does it have that echo doesn't have?


just asking. i don't know a darn thing about these two.


~~~
<SIENNA> Dude
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Raijinili
post Dec 30 2005, 02:13 PM
Post #15


Lieutenant
*************

Group: Gods
Posts: 2538
Joined: 25-December 05
Member No.: 16



Echo has uniqueness, just to make the transition between languages more difficult.

And I assume &quot; doesn't work in PHP?

What about typing <?PHP
?>?


~~~
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 4th June 2024 - 05:47 AM