Search This Blog

Showing posts with label curiosity. Show all posts
Showing posts with label curiosity. Show all posts

8/22/2012

Heredoc and Nowdoc


Heredoc and Nowdoc (also known as "here document" and "now document") are two alternative representation of strings in PHP (as double quotes and single quotes are).


This post presents these two language features and how to use them.



10/16/2011

Language Constructions

PHP language, like any programming language, is composed by language constructions. Beyond the basic programming structures (conditional, loop, classes syntax, functions syntax, etc), the language has some built-in functions. They are functions compiled in the core language.

8/13/2011

Foreach vs. For

performance

Last year, at a PHP mailing list discussion, I was surprised with the information that the loop structure "for" was faster than "foreach". After, I receive the source of that information: The PHP Benchmark. The site's author said the "for" is faster for write operations, but is slower for reading traveled items. Taking a look at the source-code, I came to the conclusion it was wrong a little strange.

5/29/2011

Binary Data at PHP Script

There is a feature in PHP that allows to embed data (including binary data) into PHP scripts and it are not parsed by PHP interpreter. It is diferent from exit instruction, that stops script execution, but does not stop the PHP parser. The feature is provided by "__halt_compiler" instruction, that ignores all data after the point it was called.

5/20/2011

PHP Delimiter

Introduction

PHP is an HTML embedded language. This means the PHP code can be inside an HTML, but should have one way to determine whether a stretch of code is PHP or HTML. The way is the use of PHP delimiters. The PHP interpreter is applicable to the stretch of code delimited by the PHP delimiters.

Some programmers use PHP code delimiters, but they do not know about their nuances. Let's see them at this post.