I'll answer your question on the web-languages: Help and Helper thread since that's where I'm trying to get all web-oriented programming languages to be discussed!
Offline
PHP I think stands for protocall-hypertext-processor or soemthing. You start a php script with tag <?php and end it with ?>
An echo basic prints text:
<?php echo("Hello"); ?>or
<?php echo "Hello"; ?>
You always end a line of code in PHP with a ;
Lets make PHP echo a variable:
<?php $variable = "hello"; echo "$variable world!"; ?>
This should echo hello world!
Understand? If so, you just learned the basics of php!
Last edited by WindowsExplorer (2011-11-11 12:48:00)
Offline
WindowsExplorer wrote:
PHP I think stands for protocall-hypertext-processor or soemthing. You start a php script with tag <?php and end it with ?>
An echo basic prints text:Code:
<?php echo("Hello"); ?>or
Code:
<?php echo "Hello"; ?>You always end a line of code in PHP with a ;
Lets make PHP echo a variable:Code:
<?php $variable = "hello"; echo "$variable world!"; ?>This should echo hello world!
Understand? If so, you just learned the basics of php!![]()
This will echo "$variable world", WindowsExplorer, since you put the variable in speech marks! you should do:
echo $variable . " world!";
__________________________________________________________-
My answer to your question: http://scratch.mit.edu/forums/viewtopic … 29#p993629
Offline
sparks wrote:
WindowsExplorer wrote:
PHP I think stands for protocall-hypertext-processor or soemthing. You start a php script with tag <?php and end it with ?>
An echo basic prints text:Code:
<?php echo("Hello"); ?>or
Code:
<?php echo "Hello"; ?>You always end a line of code in PHP with a ;
Lets make PHP echo a variable:Code:
<?php $variable = "hello"; echo "$variable world!"; ?>This should echo hello world!
Understand? If so, you just learned the basics of php!![]()
This will echo "$variable world"
nope! It will only echo $bariable word if I did single quotes. Double quotes can handle variables - I do it all the time and it works!
Offline
That's very interesting... I think I need to look into the difference between single and double quotes again. I'm pretty sure it's correct practice to keep variables outside strings and concate them though...
Offline
I'm sorry to say this sparks, but [removed by moderator] WE is right!
Double quotes can handle variables (and functions too I think) inside the quotes themselves, whereas single quotes don't and are also therefore faster.
So there are two ways to do this:
"$variable world"
or
$variable . ' world'
ninja'd
Yes, sparks, it is good practice because in other languages none of this is possible. However, we might as well take advantage of the PHP since it supports it! I myself concatenate strings because that's how I'm used to doing it in VB or C++.
Last edited by Paddle2See (2011-11-11 17:24:08)
Offline
TRocket wrote:
Php stands for PHP: Hypertext Preprossesor
Yup: it's a recursive acronym, meaning the first letter of the acronym stands for the acronym itself
At first, PHP was actually 'Personal Home Page' because it was intended to help users make their own interactive homepage. Now, the developers of PHP 2.0 (I think) changed it to something more significative.
Offline