Reply to Re: php and perl

Your name:

Reply:


Posted by Toby A Inkster on 06/13/07 08:19

peter wrote:

> thanks guys. it was useful. Being from a UNIX background, I found perl
> intuitive :) if php is c++ like, I dont think I would care for it. I
> shall see if others contribute more later.

I would say that PHP is more Perl-like than C++-like. I started PHP with a
background in Perl and found it very easy to pick up.

Here's an example to demonstrate their similarities.

Perl:

#!/usr/bin/perl

$a = 1;
$b = 1;
$c = undef;
$psi_old = undef;

print "Approximating psi...\n";
while (1)
{
$psi = sprintf('%.08f', $b/$a);
last if ($psi_old eq $psi);
$psi_old = $psi;
print "$psi\n";

$c = $a + $b;
$a = $b;
$b = $c;
}

PHP:

<?php

$a = 1;
$b = 1;
$c = NULL;
$psi_old = NULL;

print "Approximating psi...\n";
while (1)
{
$psi = sprintf('%.08f', $b/$a);
if ($psi_old == $psi) break;
$psi_old = $psi;
print "$psi\n";

$c = $a + $b;
$a = $b;
$b = $c;
}

?>

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 109 days, 15:48.]

URLs in demiblog
http://tobyinkster.co.uk/blog/2007/05/31/demiblog-urls/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация