mosiacji

Nov 22, 2009 at 07:59 o\clock

Introduction To Regular Expressions In PHP

> In Linux and Unix, the syntax that is commonly used by many applications for specifying text patterns is known as regular expressions or in short form - regex. Regex is a very powerful technique to describe patterns and many programs use them to describe sequences of characters to be matched. Search programs such as 'grep' rely heavily on regex. Basically regex forms the core in the linux world. Many scripting languages such as perl, ruby, php...etc has build in regex functions as well. So you can see, learning regular expression is important because they are used alot in many places and probably more so in the future. Regex can be scary at first but if you can get the basics, it is really not too hard to understand. In this article, we are going to look at how regex comes into the picture when writing php applications. To do a quick summary so far, a regular expression is a sequence of literal characters, wildcards, modifiers and anchors. Literal Characters Literal characters are letters, digits and special characters that match only themselves. Examples are abc, 123, ~@ and so on (some characters are reserved though). - An inclusion range [m-n] matches one of any character included in the range from m to n. Example '[a-z]' will match any alpha character that falls within the a to z range. - An exclusion range [^m-n] matches one of any character not included in the range from m to n. Example '[^0-9]' will match any non-digit character. - A period "." matches any character. It is also known as the wildcard. Example 'a.c' will match 'aec', 'acc', 'a@a' and so on. - The escape character '' enable interpretation of special characters. Example 'a.c' will match 'ac' only. Remember that '.' is a reserved character to represent a wildcard? Therefore to match a period, ie '.', we need to escape it like so '.' - The expression [:alnum:] will match all alpha-numeric characters. It is a shortcut to [A-Za-z0-9]. As you can see, it is not really a shortcut. The expression [:alnum:] might be easier to remember for some people. - The expression [:alpha:] will match all alpha characters. It is a shortcut to [A-Za-z]. - The expression [:blank:] will match a space or tab. - The expression [:digit:] will match a numeric digit. It is a shortcut to [0-9]. - The expression [:lower:] will match all lowercase letters. It is a shortcut to [a-z]. - The expression [:upper:] will match all uppercase letters. It is a shortcut to [A-Z]. unct:] will match all printable characters, excluding spaces and alphanumerics. - The expression [:space:] will match a whitespace character. Modifiers A modifier alters the meaning of the immediately preceding pattern character. - An asterisk ('*') matches 0 or more of the preceding term. Example 'a*' will match '', 'a', 'aa', 'aaaaa' and so on (Note the use of ''. It simply means that the expression matches nothing as well). - A question mark ('?') matches 0 or 1 of the preceding term. Example 'a?' will match '' and 'a' only. - A plus sign ('+') matches 1 or more of the preceding term. Example 'a+' will match 'a', 'aaaaaaa' and so on. It will not match ''. - {m,n} matches between m and n occurences of the preceding term. Example 'a{1,3}' will match 'a', 'aa' and 'aaa' only. - {n} matches exactly n occurences of the preceding term. Example 'a{2}' will match &9;aa' only. Anchors Anchors establish the context for the pattern such as "the beginning of a word" or "end of word". - The pike '^' marks the beginning of a line. Example '^http' will match any new line that starts with 'http'. - The dollar sign '$' marks the end of a line. Example 'after$' will match any line that ends with 'after'. (Variables in php starts with $. Try not to confuse with it). Grouping )' allows modifiers to apply to groups of regex specifiers instead of only the immediately proceding specifier. Example ' Enough of boring stuff, it is time to put what the theory of regex into good use. PHP Implementation There are 2 main variants of regex, Perl-compatible regex (PCRE) and POSIX-Extended. PHP offers quite alot of functions to implement these 2 types of regex. In PHP, the most commonly used PCRE function is 'preg_match' and in POSIX-extended regex, 'ereg'. Both syntax are slightly different but equally powerful. The preference to use 'preg_match' or 'ereg' is entirely up to individual although Zend suggested that preg_match is slightly faster. I prefer to use 'eregi' simply because of my background in linux administration. Example 1: Matching United States 5 or 9 digit zip codes Zip codes in USA have the following format ##### or #####-#### where # is a digit. If you want to verify the zip code submitted say from an online form, you will need to use regex somewhere in your script to verify it. The matching POSIX-extended regex pattern will be: [[:digit:]]{5}(-[[:digit:]]{4})? Confused? Wait, let me explain why. This regex is split up into 2 parts: [[:digit:]]{5} and (-[[:digit:]]{4})?. First Part: '[[:digit:]]' means the digit range and {5} means that the digit must occur 5 times. )' groups the '-[[:digit:]]{4}' together and the '?' means the expression ' -[[:digit:]]{4})' can either occur 0 or 1 time. To implement the regex in PHP, we use the following code: $pattern = '[[:digit:]]{5}(-[[:digit:]]{4})?'; if (ereg($pattern,$zipCodes)) { Example 2: Matching Dates Say we want to verify the dates entered by the user. If we only accept dates like "YYYY-MM-DD" or "YYYY-M-D", the regex pattern will be [0-9]{4}(-[0-9]{1,2})+ The '+' behind the term (-[0-9]{1,2}) means that the term must occur at least once. Note that I can also rewrite the regex as: [[:digit:]]{4}(-[[:digit:]]{1,2})+ [0-9]{4}-[0-9]{1,2}-[0-9]{1,2} As you can see, there can be many solutions to a problem... Conclusion Regex may be hard to digest at first but the logic is simple if you are able to practice more. Learning regex is as important as learning PHP. More examples can be seen at web-developer.sitecritic.net. Good luck. map mxp2 ma 3 ma m ap2 mqp3 ma p4 indx of soy nap3 map 2 mpa4 mxp2

Nov 22, 2009 at 07:58 o\clock

website templates - Professional web site templates

A professional design might decide if your next website will be a success or not. Self SEO is offering professional and affordable website templates that will save you money and time. All templates come with all source files (Photoshop and/or Flash) and all fonts that was used, so you can just download your package and start right away. Get your favourite website template now and receive bonuses such as free photo images, fonts, icons etc. If you have some questions regarding the templates or need some special customization, feel free to Professional web site templates - get yours now ! map1 indrx of progrm index of bead map 5 index of program mxp3 ,ap1 map 6 oc animas index of dowlod nap2 index off progrm map 6 of musc

Nov 22, 2009 at 07:56 o\clock

Software Articles and Software News

What is MySQL?First released in May 23, 1995, MySQL is an open source database software. It is part of a large and growing family of open source software including Linux, Apache, and programming languages PHP and Perl. However, unlike many open source products where the copyright is owned by the individual authors or distributors, MySQL is owned and sponsored by a single for-profit firm, MySQL AB, which holds the copyright to most of the codebase. They develop and maintain the system, sell ... map 6 of com putr ma2 map 2 map 5 map mao5 map 5 ma nap2 jap2 map 6 of 'rogrm map 5

Nov 19, 2009 at 19:54 o\clock

Error Occurred While Processing Request

Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debug Output Settings, and select the Robust Exception Information option. Check the to verify that you are using the correct syntax. Search the to find a solution to your problem. ma2 index of tlos ma4 ma'3 ma[1 ma;4 ma[4 index of progrm map 6 of windos map 5 the map1 ma'1 ma1 hap4 map 6 of muec index f gams map 6 of gams mxp4 map 3 the map1 map 6 of musi ma'1 mp 6 of computr maap1 map 4 ,ap2 mapp2 mp2 map 2

Nov 19, 2009 at 19:53 o\clock

Preparing for successful and professional online presences

> As becomes increasingly evident to those offering any form of practices, services, business, or information - the implied question is how to go about obtaining a website designed, developed and promoted to best meet your goals? The first step in preparing for the creation of a website - no matter who designs it or what it's for - is determining the site's basic functions and purposes . Improving trust and image of practices or business - Not having a website these days or having one that portrays an unprofessional or otherwise negative image is not a good sign to prospective customers or clients. Bringing people in from the internet - No matter what you sell or offer, there are many people already searching for it on the internet. Lacking an internet presence means web searchers won't be finding or hearing about you or your business. Attracting more offline customers - Many people will not make purchases from a person or company that they are unable to learn about or research on their own, or without dealing with representatives. Providing a 24/7 storefront to inform, build confidence and sell - While you are sleeping and your business or storefront is closed - your website is always available to persuasde and convince, allow transactions or submissions of forms, or simply provide information. Websites serve various functions depending on their purposes and goals. Specific to your practices, business, or services, you will want to create a website that offers your target audience what they want to see, and that is presented in a manner that persuades them to buy your products, contact you for information, or whatever other goals you may have for your site. A quality website developer will consult with you regarding your goals and desires and inform you of the possibilities, but as the quality and skill of webmasters greatly varies I strongly suggest getting numerous opinions if you don't like the responses you are getting from one, or are told something simply is not possible. Planning your website and understanding your goals and desires helps you best prepare your project and put it to life with your preferred website developer. Certain aspects of your website should be carefully planned in order to best establish an internet presence that meets and exceeds your goals, and most website designers will therefore want to work with you to determine the proper solutions for your project. It will be better for both you and your designer if you have thought about certain aspects of the project in advance, including: How do I want my website to look? How flashy will it be? Who will be providing the design and any graphics or other media? What will the website say - which categories and pages do you want and how many? How will the website be structured? Who will be providing the informational content, including any text? Do you want help writing or developing content? Will your site require regular updates? Would you like to make changes or updates yourself later on? Will you be selling something online? If so, what? And how will you want your transactions to be made? Will you need a database to store or retrieve information? Will you want any form submissions or other functions? Will you want users to be able to or required to log in for certain or all aspects of your website? Will you want to take advantage of for increased traffic and business? What is your timeframe and budget? What are your desires and expectations for your internet presence? Once you have planned the basics of your website you will want to find the right or for your project . Some consultants and companies specialize in most aspects of online presences, and will assist you with any or all of the above points to best establish and grow your website. Others work on just one or several areas of developing websites or online presences. The right choice for your project will depend on your particular range of services offered, the competition you will face, the market potential, your budget and timeframe, and various other factors. Choosing a wsite developer can be quite an overwhelming process, as the only people who can spot a good web developer are usually good web site developers themselves - while a website appears to most people as simply presentation and function - the truth is the elements most detrimental to any online presence's success are things that most people and even most website designers overlook or are often simply unaware of. map 3 mmap2 nap4 ma mmap1 mxp3 ma;5 ma 1 index og gams index of stuf ma'2 mmap5 the map5 index of mus c ma p1 index oc beas hap3 mxp5 ma5 index of downld ma2 ma'5 map 6 of coton index of softwar ma; 6 of chep index of aniams msp3 iindex of musc index of cmoputr

Nov 19, 2009 at 19:52 o\clock

Weighted Banner Rotating System with PHP (Web Page Editing and Hosting) - TACKtech Corp.

For the PHP people out there I converted the ColdFusion weighted rotating banner system. It is two files. Here is the first. I called it banner.php. You can call this file from a SSI include and it will run. The PHP and ColdFusion versions both do exactly the same thing in the same way just written for the different languages. Your database needs to be designed like so. <?php @ $db = mysql_connect("<--localhost-->", "<--username-->","<--password-->"); if (!$db) { echo "Error: Could not connect to DB."; $results = mysql_db_query ($dbname,$query,$db); $magicnumb = rand(0, count($prodlist)-1); $results2 = mysql_db_query ($dbname,$query2,$db); mysql_db_query ($dbname,$query3,$db); print "<A HREF="banner/redirect.php?id=$magicnum" TARGET="_blank">"; ?> The second file I called redirect.php. This page will add 1 to the click value for the banner in the database and then redirect to that site. <?php @ $db = mysql_connect("localhost", "<--username-->","<--password-->"); if (!$db) { echo "Error: Could not connect to DB."; $results = mysql_db_query ($dbname,$query,$db); mysql_db_query ($dbname,$query2,$db); ?> amp5 ma;4 map 6 of cottg ma2 index ofgams nap 6 of musc jap5 ma p2 mao5 mxp5 index of gifs ma 5 map 3 ma 2 indwx of softwae map maap2 m ap4 ma[4 map 6 of ,usc mxp5 map 2 imdex of toos map 3 amp3 ma'4 map5 the map1