PHP tutorial for a perl programmer

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Fri Nov 10 14:16:38 UTC 2006


On Thu, Nov 09, 2006 at 07:21:52PM -0500, Madison Kelly wrote:
>   I've been offered a relatively small PHP contract (outside work 
> project from my boss). Trick is, my background is perl. From the code 
> I've seen for the project it looks fairly straight forward, but there 
> are also a fair number of things I don't recognize.
> 
>   Has anyone seen a php tutorial that would be particularly suited to 
> someone who has a perl background? Rather than "this is what an if/else 
> loop is" one that has more "in perl, you would do this whereas now in 
> php you'd do that...". Thank kind of thing.
> 
>   Failing that, a php tutorial aimed at people who have a programming 
> background of any sort would be great, too.

My experience with PHP (which is quite a bit) is that you basically can
start writing code if you know C.  Most things work exactly as you would
expect it to work.  If you are not sure, do a search in the
documentation on www.php.net and there are tons of usually great user
supplied examples for each function.  If there exists a C function to do
something useful, php probably has the function too, plus a lot more to
do even more useful things.

Mapping perl onto any other language sounds rather impractical.  It's
just to messed up for that.

You can usually look at other people's php code and if you know anything
about programming you can probably figure out what it does, unlike perl.
:)

So the answer is, just jump right in.  It is really that simple.

Some small handy examples:
---showphpinformation.php---
<?php phpinfo(); ?>
---
---helloworld.php---
<HTML>
<TITLE>Hello World!</TITLE>
<BODY>Hello World!</BODY>
</HTML>
---
---helloworld-coded.php---
<?php
$text = "Hello World!";
?>
<HTML>
<TITLE><?=$text?></TITLE>
<BODY><?=$text?></BODY>
</HTML>
---
---helloworld-purecoded.php---
<?php
$text = "Hello World!";
print "<HTML>\n";
print "<TITLE>$text</TITLE>\n";
print "<BODY>$text</BODY>\n";
print "</HTML>\n";
?>
---

You can simply jump in and out of code mode from html (the default mode)
at any time with the <?php / ?> tags.  I didn't actually run any of
these examples, but php code is almost never wrong... :)

--
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list