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

php[architect]:
Pro Parsing Techniques With PHP, Part Three Using Regular Expressions
Aug 29, 2018 @ 15:55:15

On the php[architect] site they've posted the latest part of their series of magazine excerpts sharing methods for parsing text with PHP. In this third (and last) part the author focuses on the use of regular expressions. This article was originally printed in the magazine's August 2018 edition.

This is the final installment of a set of three articles offering strategies for parsing text with PHP. The first article described the basics of parsing, followed by an article on developing fault tolerant parsing strategies. This article is dedicated to regular expressions.

Regular expressions, or sometimes simply called regex, represent a powerful set of tools which allow developers to split strings, perform character substitutions, and extract text based on matched patterns. The patterns, used in regular expressions, are an actual language that describe combinations of type castings and values that match the text you want to split, substitute, or extract. Regular expressions are an enormously powerful tool for the developer who understands them.

The tutorial starts by walking through some of the basics of what regular expressions are and the functions provided by PHP (using preg_*) to work with them (including basic code examples). It then briefly talks about pattern matching with regular expressions and gives a more specific example showing phone number extraction.

tagged: phparchitect august18 parsing text series part3 regularexpression tutorial

Link: https://www.phparch.com/2018/08/pro-parsing-techniques-with-php-part-three-using-regular-expressions/

SitePoint PHP Blog:
How PHP Executes – from Source Code to Render
Jan 03, 2017 @ 18:33:41

The SitePoint PHP blog has a new tutorial posted by author Thomas Punt that walks you through the execution of PHP - a "behind the scenes" look at how the PHP processing engine does its magic.

Inspired by a recent article on how Ruby code executes, this article covers the execution process for PHP code. [...] There’s a lot going on under the hood when we execute a piece of PHP code.

He then walks you through the four main steps the engine goes through to turn your PHP code into results: lexing, parsing, compilation and interpretation. For each stage in the process there's a brief description of what piece(s) of the language are doing the work and some examples of how to see the results in more user-land PHP code (like with the AST parser).

tagged: tutorial execute language lexing parsing compile interpret

Link: https://www.sitepoint.com/how-php-executes-from-source-code-to-render/

Jani Hartikainen:
Parsing and evaluating PHP in Haskell: Part 1
Jan 17, 2013 @ 17:13:23

Jani Hartikainen has posted the first part of a series of articles sharing his experiences with an experiment he's conducting - trying to parse and evaluate PHP in Haskell.

The other day I uploaded a new experimental project on GitHub – A Haskell PHP parser / evaluator. It doesn’t understand 100% of all PHP syntax, but it was an interesting experiment nevertheless. Here’s some insights and other thoughts from working on the code.

He gets the "why?" question out of the way early, noting that it was mainly a desire to play with Haskell and figured parsing something he already knew well was a good first project. He also mentions the "Parsec" library that seems well suited for the parsing part of the process. There were some issues that he came across, however including dealing with PHP's weak typing and handling all of the possible incarnations of PHP script structure. He includes an example AST showing his different data structures (PHPValue, PHPExpr and PHPStmt). The next part of the series will be more about the evaluation of this structure.

tagged: parsing evaluation source haskell project experiment

Link:

Davey Shafik's Blog:
DateTime Timestamp Parsing
Sep 20, 2011 @ 16:24:27

In a new post to his blog Davey Shafik looks at parsing dates with DateTime, the new and improved way to handle dates in PHP (well, not so new but definitely improved).

As part of a recent project, I was tasked with taking timestamps returned by an API and displaying fuzzy dates in the final output (e.g. 3hrs ago, in 2 weeks, tomorrow). The timestamp format in question looks like: 2012-09-01T16:20:01-05:00 This format can be found in PHP as the DATE_ATOM or DateTime::ATOM constants, which contain the date() formatter string: Y-m-dTH:i:sP With this in hand, we can now easily parse the timestamp into a useful object.

Parsing the date into a DateTime object is as easy as giving it the date string and telling it how it's formatted. Then you can do all sorts of fun things. He shows how to shift the timezone by name, by time increment - simple (like "1 hour") and more complex (like "1 hour 5 minutes 3 seconds"). You can find out more about the DateTime object in the PHP manual.

tagged: datetime parsing manipulation tutorial

Link:

HowTo Forge:
PHP Programming Basics
Jan 18, 2007 @ 21:15:00

The HowTo Forge website has posted the first part in a new series of tutorials to help people (programmers and non) to get into PHP and be comfortable working with it.

This first part starts from the base they've already set (installation/configuration) and actually gets into the code.

This article is the first of a series of PHP guides that aim at teaching you the basics of PHP programming. By now, I hope you would have set up your system to start actual PHP programming. Lets start PHP programming.

They keep things simple and look at topics like:

  • What are tags?
  • Web Page Parsing
  • Operators and Operands
  • Variables

tagged: programming basics parsing tags operator operand variable programming basics parsing tags operator operand variable

Link:

HowTo Forge:
PHP Programming Basics
Jan 18, 2007 @ 21:15:00

The HowTo Forge website has posted the first part in a new series of tutorials to help people (programmers and non) to get into PHP and be comfortable working with it.

This first part starts from the base they've already set (installation/configuration) and actually gets into the code.

This article is the first of a series of PHP guides that aim at teaching you the basics of PHP programming. By now, I hope you would have set up your system to start actual PHP programming. Lets start PHP programming.

They keep things simple and look at topics like:

  • What are tags?
  • Web Page Parsing
  • Operators and Operands
  • Variables

tagged: programming basics parsing tags operator operand variable programming basics parsing tags operator operand variable

Link:

Alan Knowles' Blog:
Parsing PHP in D.
Jun 01, 2006 @ 10:51:39

Alan Knowles looks, in this new post today, at his development of a new IDE project to replace his current one, Phpmole.

Phpmole is my lifeblood for development, when I wrote it, I added all the features that where missing from other editors, and the resulting editor made a huge difference to my productivity - code folding, autocompletion, inline help hints, a list of open files, and other standard editor features as well.

However Phpmoles code base is now pretty old, and was written before I did much PEAR work. So I've started hacking on leds, the editor I mentioned before when hacking on D. It has the benefit of being relatively small codebase wise, and very easy to understand. Let alone it's fast and runs as a binary, so I can eventually just compile the lib's and distribute them, rather than a huge array of php files.

This new IDE

is mainly built with the programming language D, and, once the basics were out of the way, he integrated a PHP parser (with the help of Zend's lexer). It's not "pretty code", but it works. If you'd like to take a look, check it out here.
tagged: parsing language d IDE phpmole parsing language d IDE phpmole

Link:

Alan Knowles' Blog:
Parsing PHP in D.
Jun 01, 2006 @ 10:51:39

Alan Knowles looks, in this new post today, at his development of a new IDE project to replace his current one, Phpmole.

Phpmole is my lifeblood for development, when I wrote it, I added all the features that where missing from other editors, and the resulting editor made a huge difference to my productivity - code folding, autocompletion, inline help hints, a list of open files, and other standard editor features as well.

However Phpmoles code base is now pretty old, and was written before I did much PEAR work. So I've started hacking on leds, the editor I mentioned before when hacking on D. It has the benefit of being relatively small codebase wise, and very easy to understand. Let alone it's fast and runs as a binary, so I can eventually just compile the lib's and distribute them, rather than a huge array of php files.

This new IDE

is mainly built with the programming language D, and, once the basics were out of the way, he integrated a PHP parser (with the help of Zend's lexer). It's not "pretty code", but it works. If you'd like to take a look, check it out here.
tagged: parsing language d IDE phpmole parsing language d IDE phpmole

Link:

Spoono.com:
RSS Parsing using PEAR
May 14, 2006 @ 19:41:25

Spoono.com has posted a new tutorial today with complete details on using the PEAR XML_RSS package to parse an RSS feed.

This tutorial will show you how to use Pear (PHP Extension and Application Repository) to parse an RSS feed and display it on your site.

Pear is one of the best hidden jewels inside PHP that programmers usually don't take advantage of. In this tutorial, we're going to assume you already have Pear installed on your box. We will use the XML_RSS package from Pear to parse the top Yahoo! Technology News (located at http://rss.news.yahoo.com/rss/tech) and display it on an HTML page.

The nice thing about the completeness of the PEAR package is that it makes this tutorial a quick one - basically an install of the XML_RSS package (one line) and the code to pull in and parse out the contents of the RSS file (about eight lines). They explain it a bit, but the code makes things pretty readable and straight-forward. At the end, you'll see an amazingly simple way to pull and and parse any (properly formatted) RSS feed out there.

tagged: rss parsing use pear xml_rss package yahoo feed rss parsing use pear xml_rss package yahoo feed

Link:

Spoono.com:
RSS Parsing using PEAR
May 14, 2006 @ 19:41:25

Spoono.com has posted a new tutorial today with complete details on using the PEAR XML_RSS package to parse an RSS feed.

This tutorial will show you how to use Pear (PHP Extension and Application Repository) to parse an RSS feed and display it on your site.

Pear is one of the best hidden jewels inside PHP that programmers usually don't take advantage of. In this tutorial, we're going to assume you already have Pear installed on your box. We will use the XML_RSS package from Pear to parse the top Yahoo! Technology News (located at http://rss.news.yahoo.com/rss/tech) and display it on an HTML page.

The nice thing about the completeness of the PEAR package is that it makes this tutorial a quick one - basically an install of the XML_RSS package (one line) and the code to pull in and parse out the contents of the RSS file (about eight lines). They explain it a bit, but the code makes things pretty readable and straight-forward. At the end, you'll see an amazingly simple way to pull and and parse any (properly formatted) RSS feed out there.

tagged: rss parsing use pear xml_rss package yahoo feed rss parsing use pear xml_rss package yahoo feed

Link:


Trending Topics: