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

SitePoint PHP Blog:
Coding a Lorem Ipsum Alternative
Aug 26, 2013 @ 15:54:02

On the SitePoint PHP blog David Francis has written up an example showing how to create a "lorem ipsum" alternative in PHP. The "lorem ipsum" functionality generates text to put into layouts or prototypes of pages. It's named this way because the first two words are traditionally "lorem ipsum."

Lorem Ipsum generators are well known and are useful for generating text copy during website development. [...] t’s good that we have a wide selection of text generators, but how exactly are these generators made? Can we use PHP and MySQL to build our own? That’s exactly what we’ll tackle in this article. We won’t develop a fully working website; what we will cover are the essentials for building a site such as Fillerati.

He suggests using something from Project Gutenberg (a collection of public domain books and other written works) with the HTML markup already included. His personal choice is On the origin of the Species. He uses a simple PHP script to extract the content from the downloaded document to find useable paragraphs (don't want ones that are too long or short). He then takes that same data and populates a few database tables with it and includes the script to extract them and place them in the page. This could easily be adapted into a view helper for your favorite templating language or framework.

tagged: loremipsum alternative projectgutenburg tutorial html extract

Link: http://www.sitepoint.com/coding-a-lorem-ipsum-alternative/


Trending Topics: