Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Jani Hartikainen:
Parsing and evaluating PHP in Haskell: Part 2
Jan 23, 2013 @ 17:24:34

Jani Hartikainen has posted the second article in his series looking at parsing PHP with Haskell (part one is here). In this new article he builds on the parser he built last time and gets to the actual evaluation of the PHP code.

Last week I wrote a post about a PHP parser / evaluator I wrote in Haskell. I explained some of the parts on how the parser itself was designed to process PHP code into an abstract source tree. Continuing from where we left off in the previous part, in this post I’ll discuss the actual evaluation part.

He starts by introducing the structure of the evaluator script, how it's broken up into functionality based on the type of object/data type being handled. He uses a "custom monad transformer stack" to handle the environment for the evaluation as is progresses. He talks about handling statements and expressions, declaring custom functions and the actual execution of the function call. There's also a mention of handling conditionals/looping as well as dealing with PHP's type juggling.

if you're interested in seeing the final result (and maybe trying it out for yourself) you can find the full source on Github.

tagged: haskell parse evaluate monad transformer functions expressions looping typejuggling

Link:

Mattias Geniar's Blog:
Input Validation: Using filter_var() Over Regular Expressions
Feb 11, 2009 @ 13:55:30

This recent post to Mattias Geniar's blog takes a look at an alternative to trying to catch every single thing that could be filtered on user input with a regular expression - the filter_var function.

Just about the biggest time-sink on any project, is the amount of input validation that needs to be done. You _have_ to assume your visitor is a maniac serial killer, out to destroy your application. And you have to prevent it. [...] Thus starts our never-ending battle for user input validation. We can't allow it all so we check every value presented to us. But using PHP's filter_var function, this can be made 100x easier!

He includes the long list of filtering types that the function has to offer including sanitizing strings, working with special characters and validating input like email addresses, URLs and IP addresses.

tagged: filtervar regular expressions input validation sanitize

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [2]
Sep 27, 2006 @ 14:20:00

Harry Fuecks is back today on the SitePoint PHP Blog with part two of his "joy of regular expressions" series, continuing on from this previous entry.

He jumps right in, summarizing the first part in a small section before getting back into the examples:

  • Hunting for .jp(e)gs
  • Escaping Meta-Characters
  • Search and Replace
  • preg_quote()
  • preg_replace()
  • Word Boundaries, Word Characters...and everything else
  • Sub patterns
  • Spot the XSS Hole
  • eval() is evil!
  • preg_replace_callback()
As you can see, it's crammed with just as much infromation as the first part and covers a wide range of topics to help you get more in tune with your inner regular expression guru.

tagged: regular expressions joy example tutorial part2 preg eval meta regular expressions joy example tutorial part2 preg eval meta

Link:

SitePoint PHP Blog:
The Joy of Regular Expressions [2]
Sep 27, 2006 @ 14:20:00

Harry Fuecks is back today on the SitePoint PHP Blog with part two of his "joy of regular expressions" series, continuing on from this previous entry.

He jumps right in, summarizing the first part in a small section before getting back into the examples:

  • Hunting for .jp(e)gs
  • Escaping Meta-Characters
  • Search and Replace
  • preg_quote()
  • preg_replace()
  • Word Boundaries, Word Characters...and everything else
  • Sub patterns
  • Spot the XSS Hole
  • eval() is evil!
  • preg_replace_callback()
As you can see, it's crammed with just as much infromation as the first part and covers a wide range of topics to help you get more in tune with your inner regular expression guru.

tagged: regular expressions joy example tutorial part2 preg eval meta regular expressions joy example tutorial part2 preg eval meta

Link:

PHP.net:
Mastering Regular Expressions - now with PHP coverage
Aug 25, 2006 @ 00:13:32

On PHP.net today, there's a note about an addition to the O'Reilly classic book (an asset to any developer's library) "Mastering Regular Expressions" - a full 48-page chapter on PHP.

The book is described as:

Mastering Regular Expressions quickly covers the basics of regular-expression syntax, then delves into the mechanics of expression-processing, common pitfalls, performance issues, and implementation-specific differences. Written in an engaging style and sprinkled with solutions to complex real-world problems, Mastering Regular Expressions offers a wealth information that you can put to immediate use.

This new edition is the third release for the book.

tagged: mastering regular expressions oreilly book third edition mastering regular expressions oreilly book third edition

Link:

PHP.net:
Mastering Regular Expressions - now with PHP coverage
Aug 25, 2006 @ 00:13:32

On PHP.net today, there's a note about an addition to the O'Reilly classic book (an asset to any developer's library) "Mastering Regular Expressions" - a full 48-page chapter on PHP.

The book is described as:

Mastering Regular Expressions quickly covers the basics of regular-expression syntax, then delves into the mechanics of expression-processing, common pitfalls, performance issues, and implementation-specific differences. Written in an engaging style and sprinkled with solutions to complex real-world problems, Mastering Regular Expressions offers a wealth information that you can put to immediate use.

This new edition is the third release for the book.

tagged: mastering regular expressions oreilly book third edition mastering regular expressions oreilly book third edition

Link:

WebProNews:
Introduction To Regular Expressions In PHP
Jun 27, 2006 @ 11:11:59

Linked to from this new post on the Zend Developer Zone is a handy regular expressions tutorial that any budding PHP developer should definitely check out.

Man I hate REGEX. Not for what it does, it's a powerful weapon. It's part sniper rifle, part bazooka and extremely useful in some situations. As powerful as it is though, it is a pain to write a good REGEX query; especially when you only do it occasionally. Thankfully, Bernard Peh and the gang over at WebProNews have released a primer for REGEX in PHP that makes it a little less painful to work with.

Appropriately titled Introduction To Regular Expressions In PHP, the article starts with a basic REGEX primer. It's sparse on details but it discusses the different types of characters in a REGEX query. Properly formatted, this would be a great little cheat sheet to have handy.

Cal (on the Zend site) mentions that it's a good starting place, but they don't get too deep into the meat of the matter, showing more than just the basics of "this is what this character does". Oh well, I suppose maybe that's being saved for part two...

tagged: introduction tutuorial regular expressions introduction tutuorial regular expressions

Link:

WebProNews:
Introduction To Regular Expressions In PHP
Jun 27, 2006 @ 11:11:59

Linked to from this new post on the Zend Developer Zone is a handy regular expressions tutorial that any budding PHP developer should definitely check out.

Man I hate REGEX. Not for what it does, it's a powerful weapon. It's part sniper rifle, part bazooka and extremely useful in some situations. As powerful as it is though, it is a pain to write a good REGEX query; especially when you only do it occasionally. Thankfully, Bernard Peh and the gang over at WebProNews have released a primer for REGEX in PHP that makes it a little less painful to work with.

Appropriately titled Introduction To Regular Expressions In PHP, the article starts with a basic REGEX primer. It's sparse on details but it discusses the different types of characters in a REGEX query. Properly formatted, this would be a great little cheat sheet to have handy.

Cal (on the Zend site) mentions that it's a good starting place, but they don't get too deep into the meat of the matter, showing more than just the basics of "this is what this character does". Oh well, I suppose maybe that's being saved for part two...

tagged: introduction tutuorial regular expressions introduction tutuorial regular expressions

Link:


Trending Topics: