News Feed
Sections




News Archive
feed this:

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

Nikita Popov's Blog:
The true power of regular expressions
June 15, 2012 @ 08:42:57

Nikita Popov has a new (language agnostic) post to his blog today about one of the most powerful things you can use in your development - something that a lot of developers don't understand the true power of - regular expressions.

As someone who frequents the PHP tag on StackOverflow I pretty often see questions about how to parse some particular aspect of HTML using regular expressions. A common reply to such a question is: "You cannot parse HTML with regular expressions, because HTML isn't regular. Use an XML parser instead." This statement - in the context of the question - is somewhere between very misleading and outright wrong. What I'll try to demonstrate in this article is how powerful modern regular expressions really are.

He starts with the basics, defining the "regular" part of "regular expression" (hint: it has to do with predictability) and the grammar of the expressions. He talks about the Chomsky hierarchy and how it relates to the "regular" as well as a more complex mapping of expression to language rules. He talks about matching context-free and context-sensitive languages and unrestricted grammars as well.

0 comments voice your opinion now!
power regular expression define theory context


Chris Roane's Blog:
What does it mean to be an Advanced PHP Programmer?
June 06, 2011 @ 09:42:28

In a new post to his blog Chris Roane has a few suggestions about advanced programming and what it might take to be considered an advanced programmer in any language.

On a previous post I had someone comment that they did not agree that the code implementation that was presented in the article was advanced (which was described in the title). They also claimed that I was not an advanced PHP programmer. This made me think. Not because my programming skill or knowledge was challenged. But because I'm not sure what makes code or a programmer "advanced".

He asks a few questions about the criteria for considering someone an "advanced programmer" including things like how fast or efficient they are, how much they make or the conference(s) they've been to. He points out that, because "advanced" is such a relative term, it's hard to put a finger on it. Being this hard to define (and mostly worthless even if it is) he suggests an alternative to trying to figure it out:

Instead of throwing around general terms in labeling code or other programmers, let's come together and figure out ways in improving code together. Practical applications.
0 comments voice your opinion now!
advanced programmer opinion criteria define


Jonathan Snook's Blog:
Multiple Validation Sets in CakePHP 1.2
July 23, 2008 @ 07:51:27

Jonathan Snook has posted two methods for creating multiple validation sets in the latest version of your CakePHP application.

In CakePHP, you define how your data should be validated by setting parameters on the validate property of your model. In version 1.2, there is an on option that can be set on a specific rule that, when set, is either create or update. [...] Despite that, I developed a slightly different approach that allows for different validation sets to be specified and to be cleanly separated from each other.

He overrides the validates() method with his own in a custom model in one of two ways - having the script check for a validation set for the current controller or by specifying it directly with a validationSet property. Code for both methods is included.

0 comments voice your opinion now!
cakephp framework validation set detect controller property define tutorial


Hasin Hayder's Blog:
Web scrapping in a smart way, making a "Today in History" object in PHP
April 29, 2008 @ 10:27:41

Hasin Hayder has written up a quick tutorial for his blog that shows how to create your own "Today in History" page with details from Scopesys pulled with a little web scraping.

There are thousands of services available on web who are presenting interesting as well as education information which you can really integrate in your web page or make a nice widget and let others use them seamlessly with their content delivery platforms. In this article I am going to show you how you can make a nice Today-in-History widget with the help of the data provided in Scopesys.

He wisely recommends that you check one thing first about the content you're grabbing - the copyright it carries with it. This could get you into big trouble down the line depending on whose content it is. The actual script is pretty simple - he defines some constants as markers for where things start and stop in the HTML and then uses strpos to get the locations for his substr call to grab the segments.

0 comments voice your opinion now!
todayinhistory widget copyright scopesys constant define substr strpos


WebReference.com:
The Building Blocks Data Types, Literals, Variables, and Constants - Part 3
January 29, 2007 @ 11:44:00

WebReference.com has posted part three of their "Building Blocks" series - a look at data types, literals, variables, and constants.

In part three, they focus more on the last type of "block" in their list - the constant:

Some real-world constants, such as pi, the speed of light, the number of inches in a foot, and the value of midnight, are values that don't change. PHP not only provides its own predefined constants but lets you create your own. Using constants makes it easy to write and maintain your programs.

There's talk of the define() and constant() functions and a mention of some of the predefined and "magic constants" as well.

0 comments voice your opinion now!
building blocks variable constant define magic building blocks variable constant define magic


Felix Geisendorfer's Blog:
Include only the JS you really need
November 20, 2006 @ 07:46:00

In his latest entry, Felix shares a quick tip for CakePHP users out there to help them reduce the sizes of their pages and speed things up a little bit by including only the Javascript that you really need as a method inside your controller.

The basic idea is the addition of two functions and a variable to set the jsIncludes value and an includeJs/excludeJs pair to do the actual loading. The result is a much cleaner call to includeJs when rendering the application that will automatically pull in the files specified.

So if up to now you've always included all JS for every page load, this might help to reduce bandwidth usage for both you, and the users of your application. I know this is not the most advanced solution one could come up with. [...] But then I decided that it's too simple a problem for that kind of bloat.

All of the code is included here.

0 comments voice your opinion now!
cakephp javascript include define function variable controller cakephp javascript include define function variable controller


PHPBuilder.com:
BitMasks Emulate Unix Permissions in PHP (Quickly)
August 09, 2006 @ 16:01:53

Permissions in Unix-based systems have become one of the standard models for development all over the world. They're simple to learn and use while being extremely powerful at the same time. In this new article (as contributed by Eric Potvin) from PHPBuilder.com today, they bring this power to the realm of PHP with bitmasks.

Bitmasking is a very useful method to emulate Unix-style file permissions (read/write/execute for example). What's nice about a PHP implementation is that you can configure your own bitmasks and use them for any kind of permissions in your scripts and applications. The implementation is relatively simple as well.

They start by defining a few of the permission levels (add/delete/denied) in PHP constants before showing the bitMask() function you can use to check a user's permissions. They also include some simple pseudo-code to show how it's used. For more information, check out the complete article here.

1 comment voice your opinion now!
bitmask unix permissions tutorial define constants bitmask unix permissions tutorial define constants


Vidyut Luther's Blog:
"Where do you 'define' your environment variables" ...update/workaround/s
January 23, 2006 @ 06:41:21

On his blog, phpcult.com, today, Vidyut Luther has posted an update to his previous post asking where people usually define their settings.

My last post created a lot of conversation about how one should go about setting configuration options for your code. I realized, no one mentioned the use of PHP's built in parse_ini_file.

function. This seems to address my problems with one large monolothic file pretty easily. I can still have a globals.conf.php which handles global settings, but I can also use this ini file, to load specific things that are only necessary for modules on an as needed basis. The global scope would be aware of the CONFIG_FILE constant, and I can parse specific sections of it whenever I need to.

He notes that he'll try it in the next few days, but I imagine he'll like what he sees - especially if he's looking for a simple, external way to change information in a file and have it affect the entire app (without changing code).

0 comments voice your opinion now!
define environment variables update parse_ini_file define environment variables update parse_ini_file


Vidyut Luther's Blog:
Where do you "define" your environment/global settings?
January 20, 2006 @ 06:44:36

From Vidyut Luther today, there's this new post that asks the question "Where do you 'define' your environment/global settings?"

I was wondering how people handled this situation themselves. I'm personally trying to decide whether my constants be in the class files, or a global configuration file. Right now I have a global.conf.php which contains things like (MySQL login info, include paths, table names).

So, my question is: Is it better to have one big configuration file, or should some things be defined on top of the individual classes ? (CONTACTS_TABLE.. is a clear example). I see pros and cons for both approaches.

He lists out pros and cons for the "one file approach" versus the "multiple specific definitions" method, for example:

  • simple editing vs. easier to manage
  • a single large file vs. multiple small files
  • high memory usage on every page vs. lower memory consumption from loading only what's needed
0 comments voice your opinion now!
define global settings multiple file single large small define global settings multiple file single large small



Community Events





Don't see your event here?
Let us know!


release opinion tool voicesoftheelephpant series introduction library security podcast example framework language community laravel conference symfony list composer interview version

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework