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

PHPMaster.com:
Working with Multibyte Strings
July 18, 2013 @ 10:12:55

On PHPMaster.com there's a tutorial posted that helps you understand how to work with multibyte strings in PHP. Multibyte strings could be a set of characters from a non-English language. They have to be treated differently than normal strings using the mbstring functionality.

A written language, whether it's English, Japanese, or whatever else, consists of a number of characters, so an essential problem when working with a language digitally is to find a way to represent each character in a digital manner. Back in the day we only needed to represent English characters, but it's a whole different ball game today and the result is a bewildering number of character encoding schemes used to represent the characters of many different languages. How does PHP relate to and deal with these different schemes?

He goes through a bit of introduction to multibyte strings - how they're represented internally, character schemes and Unicode. He also talks about the PHP support for the strings, noting that it's not really made to deal with them by default and the two methods you might use - iconv and mbstring. He shows how to enable the latter and introduces some of the most common functions you'll use with it (complete with some code examples).

0 comments voice your opinion now!
multibyte strings tutorial mbstring introduction unicode

Link: http://phpmaster.com/working-with-multibyte-strings

DevShed:
Working with Strings and the Composite Pattern in PHP 5
March 14, 2007 @ 11:14:00

DevShed has posted the second and last part of a series of two articles based around the Composite design pattern - using it to work with strings in PHP5.

Are you a PHP developer who wants to improve your skills in pattern-based programming in PHP? If the answer to this question is a emphatic yes, then you should begin reading this article now! Welcome to the final part of the series "Implementing the composite pattern with PHP 5." Comprised of two instructive tutorials, this series walks you through the basic concepts of this important design pattern, and shows you how to apply it with some educational examples.

They start by defining a simple StringProcessor class as an abstract interface to build from. From there, they create two other classes - the SingleStringProcessor and the MultipleStringProcessor. Each of these takes in either a single file or multiple filenames and spits back out the value of the string and the length of the string.

0 comments voice your opinion now!
tutorial composite designpattern strings single multiple tutorial composite designpattern strings single multiple


International PHP Magazine:
November 2006 Issue Released
November 08, 2006 @ 08:57:00

From the International PHP Magazine, the latest issue has been released - November 2006 - and is available for order over on their website.

Contents of this edition include:

  • The cover story, "Automated Tests with PHPUnit 2" by Stefan Priebsch
  • Elizabeth Naramore's "Freelancers Corner"
  • Marc Isikoff talking about "Strings and Arrays"
  • Arjen Lentz looking at the transactional storage engine, Falcon, that MySQL offers
You can check out the full table of contents to see what else the issue has in store, or just head over and subscribe to this great PHP publication.

0 comments voice your opinion now!
itnlphpmag issue release nov2006 phpunit strings arrays mysql falcon itnlphpmag issue release nov2006 phpunit strings arrays mysql falcon


Zend Developer Zone:
PHP Gotchas!
April 24, 2006 @ 12:49:58

The Zend Developer Zone has a new post for those out there struggling with the small stuff. You've got the language down and you're learning the syntax, but there's still a few things that elude your grasp. If this is you, check out their list of "PHP Gotchas" to see if your problem is on there.

Call them obscure, call them pointless, call them "newb mistakes." Whatever you call them, you've more than likely been tripped up at some point in your PHP coding journey by seemingly odd or illogical behaviors of the language. With PHP being a loosely-typed language, funny things are bound to happen.

PHP is an easy language to pick up for the casual coder--things should "just work." But not everyone comes into PHP development with a strong programming background, so here are some charming examples of ways PHP can trip you up if you aren't careful. Put on your thinking caps--here comes the science!

Included in their list of common problems for budding PHP developers are things like finding a "needle" in a string "haystack", working with constants, using and/or, and the __toString functionality in PHP5.

0 comments voice your opinion now!
gotchas strings constants tostring logic math gotchas strings constants tostring logic math


PHPBuilder.com:
Preventing spam when using PHP's mail function
April 12, 2006 @ 15:47:45

Spam has grown into one of the worst problems on the internet today. It effects everyone, even those that guard their email addresses with their lives. Information spreads so fluidly in the bits and bytes of everyday communication, that it's almost inevitable for your address to get out. Once it's out, you'll know, getting emails from people you don't know offering things you don't want. One tool spammers can use, unfortunately, are the unsecured forms on your own site. Thankfully, there's articles like this one from PHPBuilder.com that can help you safeguard your site against these attacks.

Insecure PHP scripts have provided great opportunities for spammers to abuse other's resources to send out their spam. In particular, it's the mail() function that can be abused. I myself was the target a few months ago when I noticed spam being sent from an old form on my server that I'd forgotten about. This month's article looks at techniques that can be used to harden your mail form, and reduce the chances of it being misused.

They set up the simple example script and show you how to exploit it to follow the wishes of potential spammers. They offer a few suggestions on hardening the form - filtering for a correct email address, checking for "bad strings" in the contents of the form, and looking for a REQUEST_METHOD value in the $_SERVER array. The methods aren't fool-proof, but they can help to dramatically reduce your chances of being the source of a lot of people's annoyance.

1 comment voice your opinion now!
mail prevent spam filtering bad strings request_method mail prevent spam filtering bad strings request_method


Greg Beaver's Blog:
comparing strings in PHP with the == operator
December 16, 2005 @ 07:11:30

On Greg Beaver's blog today, there's his look at string comparison with the "equals equals" (==) operator in PHP and some issues he found around it.

Recently, an obscure detail in the way PHP processes strings came to my attention in the form of an endless loop occasionally found in phpDocumentor's parsing of a file.

This is processed by code that checks for simple lists (like 1. blah 2. blah, or - blah - blah, etc.). However, an innocent call to in_array($x, array('1.', '0.')) had surprising and unexpected results: our friendly PHP determined that '01' was in the array('1.', '0.')!! This is of course patently false, and made little to no sense until I realized that unlike my previous understanding (when comparing an integer to a string, the string is converted to an integer), PHP actually converts all numeric-like strings into integers when comparing them.

To help avoid these kinds of situations repeating themselves, he makes a few suggestions when comparing your values: "use === instead of ==", "use the third parameter in in_array, set to true", and "use strcmp() or one of its cousins". In his opinion, though, this kind of auto-conversion is a bit dangerous - bit it's all about perspective...

0 comments voice your opinion now!
compaing strings auto-converstion in_array strcmp compaing strings auto-converstion in_array strcmp



Community Events





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


symfony interview podcast update tool laravel release package library voicesoftheelephpant community mvc version language framework introduction composer opinion series security

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