JavaScript Editor Ajax software     Free javascripts 



Main Page

Unlike with mod_rewrite, when you supply a regular expression to a PHP function you need to enclose
the regular expression definition using a delimiter character. The delimiter character can be any character,
but if the same character needs to appear in the regular expression itself, it must be escaped using the
backslash (
\
) character. The examples here use
#
as the delimiter. So if your expression needs to express
a literal
#
, it should be indicated as
\#
.
Rewriting Numeric URLs with Two Parameters
What you’ve accomplished in the previous exercise is rewriting numeric URLs with one parameter. You
now expand that little example to rewrite URLs with two parameters.
The URLs with one parameter that you supported looked like
http://seophp.example.com/
Products/Pn.html
. Now assume that your links need to support a category ID as well, not only a
product ID. The new URLs will look like this:
http://seophp.example.com/Products/C2/P1.html
The existing
product.php
script will be modified to handle links such as:
http://seophp.example.com/product.php?category_id=2&product_id=1
For a quick reminder, here’s the rewriting rule you used for numeric URLs with one parameter:
RewriteRule ^Products/P([0-9]*)\.html$ /product.php?product_id=$1
PHP Function
Description
preg_match_all
Similar to
preg_match
, but all matches are searched. After one match
is found, the subsequent searches are performed on the rest of the
string. More details at
http://www.php.net/preg_match_all
.
preg_quote
Escapes all special regular expression characters of the input string
using the backslash character. More details at
http://www.php.net/
preg_quote
.
preg_replace
The function replacing matching parts of a string with a replacement
expression. It receives three non-optional parameters: the pattern
used for matching, the replacement expression, and the input string.
More details at
http://www.php.net/preg_replace
.
preg_replace_callback
Similar to
preg_replace
, except instead of a replacement expression,
you specify a function that returns the replacement expression. More
details at
http://www.php.net/preg_replace_callback
.
preg_split
Splits a string on the boundaries matched by a regular expression. The
resulting substrings are returned in the form of an array. More details
at
http://www.php.net/preg_split
.
61
Chapter 3: Provocative SE-Friendly URLs
c03.qxd:c03 10:39 61


JavaScript Editor Ajax software     Free javascripts 
Bitcoin Gambling - The Original Crypto Dice Game . https://paperhelp.link