Skip to content

So far, so good…

August 3, 2006

So far, PHP seems pretty straightforward – the syntax is a bit different than anything I’ve used before (the manuals reference C, which I’ve never written in) but the 4-5 pages I’ve put together so far have all worked.

Error codes

One thing I have noticed – which may just be a function of the hosting company I’m using – is that syntax errors in the PHP code seem to suppress all output of the page. This could cause a problem when I’m not copying code verbatim? I found this out when I tried deleting the trailing semicolon from one line in the sample pages – to see what happens if I mistype something in production.

In ASP, I’d get some level of error code to help me track down what went wrong. In Coldfusion I’d get an echo of the line of code with the error, two lines before, and two lines after. With PHP I didn’t get anything. I’m guessing this is because the hosting company I’m using has suppressed error messages (which can help people find out server information) – but I’m not quite sure yet. Any suggestions?

Tags vs. programming

Something I’m glad about is that PHP, like ASP, is less a set of tags than a scripting language for authoring HTML on the fly. This contrasts with Coldfusion, which is basically only a set of tags.

What I mean by this is that, in ASP, I can string together huge functions, put in all sorts of programming logic, and only incidentally output HTML code. This is because an ASP page is an amalgamation of HTML and VBscript. The HTML code is static, while the ASP code allows for loops, if/then statements, arrays, etc. PHP seems to be the same way – once you enter PHP-land with a < ? tag, you're free to do just about anything you want.

With Coldfusion, though, it’s all done with tags – and there are some things you just can’t do – like nested cfoutput tags to loop through two query results simultaneously. Yes, you can dump one/both resultsets to an array and loop through them that way, but you end up having to do a few more backflips to get your data to a workable state.

Regular expressions

I’ve seen postings on mailing lists about “regular expressions”. I’ve never used them personally, but the impression I have is that they’re a method for parsing a string looking for certain rules to be followed – and actions to be taken based on those rules. 

It seems like I might finally get to /have to become more familiar with them, now. I saw a few PHP functions in perusing the manual that try to correctly capitalize a string of submitted text – and they seemed to use regular expressions. Maybe some of you would know this for sure, but when I see this function:

eregi("^([^&]*)(&)(.)([a-z0-9]{2,9};|&)(.*)", $string, $regs)

that’s a regular expression? Or am I even more clueless about this than I thought I was? That line of code, by the way, comes from the second visitor comment on the PHP strtoupper manual page.

Concluding thoughts

It’s late, and I’m heading to bed – I’ll post more later as I continue this madness. Hopefully soon I’ll have figured out an actual project, so I can start making progress towards a larger goal.

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: