PHP notes for Java/C# programmer - set 1

Are you a Java/C# programmer looking for a crash course on PHP? Here is an easy way. In the next 5 days I will be going through the entire PHP documentation and will be taking notes which are relevant and unique to PHP.

I am a hardcore Java programmer and hence by following me you can quickly learn PHP! My notes will be mainly based on the online PHP manual. Here is the first set of PHP notes.

General PHP Notes

1. PHP - PHP:Hypertext Preprocessor is an open source general purpose scripting language.

2. PHP can be used for server side scripting, command line processing and as a GUI application (PHP-GTK).

3. PHP is changed to a proper object oriented language from version 5 onwards and allows OOP paradigm.

4. First sample program, the famous “Hello World”,

<html>
<head><title>Hello World</title></head>
<body>
<?php echo “Hello World” ?>
</body>
</html>

5. PHP exposes a set of superglobal variables accessible from anywhere. For example, $_POST superglobal can be used to extract http post parameters. $_POST is an associative array.

6. If the HTML form field name contains a dot(.), it is converted to an underscore(_) automatically by PHP. For example, if the text field name is “user.name”, you should use $_POST[”user_name”] to retrieve its value!

7. There are a couple of mailing lists available for PHP. It is at http://www.php.net/mailing-lists.php. So far I have only subscribed to “Announcements”.

Next set of PHP notes on the language features will be published tommorrow.

2 Responses to “PHP notes for Java/C# programmer - set 1

  • 1
    Binny V A
    March 28th, 2007 00:29

    I have been using PHP for the last 2 years - but I did not know about PHP changing the . to _ in form names. Thanks for the info.

    Waiting for the next article.

  • 2
    Sami
    April 23rd, 2007 20:44

    excellent articles! here’s some other nitty gritty php tips:
    with arrays, you can “leave it open” unlike other langs ie.
    $a = array(1,2,3,); the last comma is not a typo. very useful when having the array in multiple lines and extend it with values at a later time. I would like to see this in other langs aswell! with echo, you can use , insted of . to concatenate. well it’s not a concat exactly but every block will be echoed separetly not concatenated, so it saves some processpower. ie. echo ‘a’ , ‘b’ , ‘c’; is the same as echo ‘a’; echo ‘b’; echo ‘c’;

Leave a Reply