FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » What *tasks* are hard for PHP?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: What *tasks* are hard for PHP? [message #172064 is a reply to message #172040] Sat, 29 January 2011 05:50 Go to previous messageGo to previous message
Curtis Dyer is currently offline  Curtis Dyer
Messages: 34
Registered: January 2011
Karma:
Member
"P E Schoen" <paul(at)pstech-inc(dot)com> wrote:

> "axtens" wrote in message
> news:97691f21-90c5-42a6-8b63-76ae6154883d(at)d23g2000prj(dot)googlegroup
> s.com...
>
>> I've asked this question on my blog. See

<snip>

>> I just want to
>> get an idea of what can and can't be done with PHP at the task
>> level.

Others have already pointed out the issues with the vagueness here.

> Most of the comparisons I've found are biased one way or
> another. Coming from a background of relatively strongly typed
> languages such as Borland Delphi and C, I have found both of
> these interpreted languages frustrating and difficult to
> understand.

<snip>

> It is handy to be able to include PHP within HTML. There are
> many sometimes conflicting modules for Perl (such as DateTime).
> PHP does not seem to have the equivalent of Strict, Warnings and
> Taint checking. And I found PHP file I/O to be simpler (or more
> C-like):

Well, PHP does a decent job when you set the error level to ``E_ALL
| E_STRICT''. As for adding a taint mode, I believe there may be
third-party options, but I haven't searched extensively.

> Here is an example of straightforward and simple file I/O in
> PHP:
> $fHTMLrawfile = "Raw.htm";
> $fHTMLraw = fopen($fHTMLrawfile, 'r') or die("can't open
> file"); if (filesize($fHTMLrawfile) > 0)
> $html = fread($fHTMLraw, filesize($fHTMLrawfile));
> else
> $html = 'N/A';
> fclose($fHTMLraw);

A more straightforward approach (with error checking):

<?php

$file = 'foo.dat';

if (is_readable($file)) {
if (($data = file_get_contents($file)) !== false)
$data = $data ? $data : 'N/A';
}

?>

> A similar operation in Perl requires line by line iteration (or
> possibly a lower level function, or reading into an array and
> then assembling the string):
> if (-e $HTMLpurefile){
> open (fHTMLpure, '<', $HTMLpurefile);
> my $line;
> $in{$key} = "";
> while( $line = <fHTMLpure> ){
> $in{$key} .= $line;
> }
> close fHTMLpure; }

<OT>

Not necessarily that complicated, you can slurp the file into a
string.

# see: perlvar
{
open my $fh, '<', 'foo.dat' or die $!;
local $/ = undef;
my $data = <$fh>;
close $fh;
}

</OT>

> I now have a PHP script which is executed within my Perl script,
> but I might consider rewriting the entire thing in PHP. Maybe it
> would be a good learning experience to try a bit more than a
> trivial helper script in PHP, and then I'll be able to make a
> more educated choice. At this point, I don't really like either
> one. Maybe I should just do it in C!

Unless you feel motivated to take on the academic task of better
learning PHP, or any other language for that matter, I'd recommend
using the language with which you're most comfortable.

<snip>

--
Curtis Dyer
<?$x='<?$x=%c%s%c;printf($x,39,$x,39);?>';printf($x,39,$x,39);?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Sanitising input
Next Topic: php include question
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 02:59:13 GMT 2024

Total time taken to generate the page: 0.05654 seconds