PHP equivalents of Perl
Hello,
I'd like to port some perl code to PHP.
PHP looks a lot like perl and javascript to me, but there's a few
things I'm confused about, please f****ve the pseudo PHP syntax.
####
Perl lets you assign a "function" to an array, we call that a hash table
in perl.
So, can you do this in PHP?:
$y='Hello';
$my_custom['echo_foo']=function echoFoo($x){
return $x;
}
if($my_custom['echo_foo']){
echo $my_custom['echo_foo']($y);
}
####
Perl has CGI.pm where you can create form elements easily, for ex:
$popup=$query->popup_menu(-name=>'subsection',-default=>'some_default',-values=>'....);
Is there a library similar in PHP?
####
In Perl you can execute a function in a regular expression
substitution:, so that you can take the regex match and feed that to a
function, the return value from that function is then substituted in for
the match. How is this done in PHP?
####
How about a simple example of saving an uploaded file to the server?
###
Perl lets you make a reference to a variable, is there anything like
this in PHP?
###
What about error handling, perl is wonderful in this. How are errors
handled in PHP?
If there's a good tutorial on porting let me know, I've been
looking... Or just a good PHP tutorial. I'm still confused about scoping
in PHP...
Jeff
|