PHP uses a JIT(Just in Time) compiler so you never have to compile your code. All you have to do is put the code on a server and call it from a web browser and it will compile and run for you. You should put your .php files in to the public_html folder in your home directory of your cislinux account, and then you can run the code by going to http://people.cis.ksu.edu/~eid/helloworld.php replacing eid with your eid.
If you have never used your public_html folder you may have to set the permissions on the folder so that it will work: CIS Department Support (Thanks to Wade Wilson for providing me this link).
PHP files output HTML for the browser to display. All php code needs to be put in tags. Anything outside of the tags will be interpreted as plaintext and displayed to the browser.
A very basic helloworld.php page is: Output
echo "Hello World";
// is for comments just like java; /* */ can be used for multi-line comments
echo is used to write strings or variables to the output. Similar to java or C++ all lines of code end with a semicolon.
Here is a more complicated helloworld2.php: Output
$hello = "Hello";
$world = "World";
echo $hello . " " . $world;
In this helloworld I set 2 variables containing the strings hello and world. Variables do NOT need to have a type defined to them such as int or string. Also all variable names are required to start with a $.
In the echo I output the 2 variables and I put a space in between them. In php the period is used to concatenate strings. Putting a + like in Java or C++ will not work.
If you want/need to start a new line in the output you should use echo to write HTML tags to the output, such as:
echo "<br />";
You can have many pairs of PHP tags throughout the code, so if you have a large section that is going to be HTML with nothing extra you can close the tag, write the HTML and then reopen the tag.
$var ="Hello World";
This also works with php control structures such as loops and if statements
This can make for some complicated code, but it's sometimes better than echo'ing a bunch of tags out, especially if they have quotation marks in them. If you do have to output a quotation mark from an echo use \" in the string.
Any errors in your code will be displayed on the page and all code after the error occurs will not run.
Arraying in PHP are special. You do not need to declare the array. You do not need to specify the size of the array. It's all dynamic. Also you can reference arrays with strings or numbers. So:
will work or
will work. So long as you can remember where you stored the data. You can even mix strings and numbers in the same array.
2 dimensional arrays are just as you would expect
or you can use a combo of numbers and strings in them
Other than that most stuff in PHP is very straight forward and similar to Java or C++. Refer to the PHP manual at http://php.net/manual/en/index.php or the W3schools guide at http://w3schools.com/php/default.asp to figure out the rest.