Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
More bad stuff:
  • Basically only two kinds of variable scope: global and local to a function. That means that if you have several PHP files that are intended to be used together, and just "do things" that are not wrapped inside a sub 'er, "function"), that they'll stamp on each others variables. There's no way to limit a variable's scope to "just this block" or "just this file".
  • Guess what value the variable $x will have after the loop finishes?
    # PHP code $x = 'foo'; $row = array('a', 'b', 'c'); foreach ($row as $x) { echo "$x\n"; }
    I'll tell you: loop variables are not localized. Stomp stomp stomp.
  • No support for placeholders in database access *. That means that you have to produce literal SQL strings to execute, by incorporating the data in the SQL statement. It's slow if you have to do this many times in a loop. But, in order to prevent people form accidently creating invalid SQL this way, GET and POST values are pre-addslashes()-ed by default! Talk about doing a patchup in the wrong place!

Update: broquaint pointed out that PHP does have support for placeholders, which is a good thing. I must say that none of the PHP developers I've spoken to, has ever even heard of them. So use of placeholders in PHP doesn't seem very commonplace. However, my complaint on the automatic addition of backslashes on special characters in form variables still stands, which was my main gripe in that point.

The phrase "It has about as much support for placeholders as perl does natively" is one I just cannot grok. Perl does not have native SQL database support without DBI. DBI is the way to access SQL databases in Perl. Using placeholders is one of the first things you learn there. OTOH, AFAIK they're hardly even mentioned on PHP's manual website, and only under Oracle and ODBC. Don't you just hate it that every database has its own kind of access functions.


In reply to Re: Re: PHP vs Perl code compare by bart
in thread PHP vs Perl code compare by mandog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2023-09-21 10:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?