f



Regular expression example on PHP.net

Howdy folks,

On this page at php.net
    	http://www.php.net/features.http-auth
there's a regular expression in Example 34.2.  It's supposed to parse out 
the different values being passed in the header.  I know what it's 
supposed to do, so I have a vague idea of what's being done in the RE, 
but I've been having a heck of a time figuring out what each part of the 
RE is actually doing.  Here's what I have so far:

preg_match_all('@(\w+)=(?:([\'"])([^\2]+)\2|([^\s,]+))@', $txt, $matches, 
PREG_SET_ORDER);

//'@
//(\w+)		Any word character (letter/digit/_), 1 or more
//=			Equal sign
//(?:		    	This submatch will not be captured (still available for 
later matching)
//([\'"])		A single or double quote
//([^\2]+)	    	Not start of text (STX)?, 1 or more
//\2|
//([^\s,]+)	    	Not whitespace or comma, 1 or more
//)
//@'

I'm unclear as to what the second \2 does, as well as which parts the OR 
applies to.  And what are the @s for?

Thanks for any help,
ZF

-- 
Posted via a free Usenet account from http://www.teranews.com

0
9/7/2007 6:02:07 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

9 Replies
575 Views

Similar Articles

[PageSpeed] 58

On Fri, 07 Sep 2007 08:02:07 +0200, Zenofobe <fake_email@fake_domain.com=
>  =

wrote:

> Howdy folks,
>
> On this page at php.net
>     	http://www.php.net/features.http-auth
> there's a regular expression in Example 34.2.  It's supposed to parse =
out
> the different values being passed in the header.  I know what it's
> supposed to do, so I have a vague idea of what's being done in the RE,=

> but I've been having a heck of a time figuring out what each part of t=
he
> RE is actually doing.  Here's what I have so far:
>
> preg_match_all('@(\w+)=3D(?:([\'"])([^\2]+)\2|([^\s,]+))@', $txt, $mat=
ches,
> PREG_SET_ORDER);
>
> //'@
> //(\w+)		Any word character (letter/digit/_), 1 or more
> //=3D			Equal sign
> //(?:		    	This submatch will not be captured (still available for
> later matching)
> //([\'"])		A single or double quote
> //([^\2]+)	    	Not start of text (STX)?, 1 or more
> //\2|
> //([^\s,]+)	    	Not whitespace or comma, 1 or more
> //)
> //@'

Quick tip for starting with regexes: use the x modifier, so you can  =

comment this is in the regex itself for later.

preg_match_all('@ #starting delimiter
      (\w+)        #any word character (one er more) in match 1
      =3D            #literal '=3D'
     (?:           #start of non-capturing subpattern
       ([\'"])     #either \' or " in match 2
       ([^\2]+)    #match one or more characters in match 3 that are NOT=
 in  =

match 2
       \2          #match the same character as matched in 2
       |           #or
       ([^\s,]+)   #character not whitespace or comma in match 4
     )             #end of non-capturing subpattern
     @             #ending delimiter
x', $txt, $matches,PREG_SET_ORDER);

> I'm unclear as to what the second \2 does,

It's a 'reference' to the match allready captured in match 2

> as well as which parts the OR
> applies to.

The pattern seems to try to capture name/value pairs, where either the  =

value is quoted with a ' or ", or consist of "characters not whitespace =
or  =

comma". So it will match "foo=3D'bar'" & "foo=3Dbar", but in "foo=3Dbar =
baz"  =

still only 'bar' will be matched in 4, not 'bar baz'.

> And what are the @s for?

(Almost) any character can be used as 'delimiter' of the pattern, usuall=
y  =

/, but it's @ here. Being able to choose a delimiter for the pattern hel=
ps  =

you to avoid having to quote an often matched character that is used as =
a  =

delimiter. Any characters following the second delimiter (x in mine) wil=
l  =

be considered modifiers to the pattern.
-- =

Rik Wasmus
0
9/7/2007 7:56:02 AM
On 07.09.2007 09:56 Rik Wasmus wrote:

>       ([^\2]+)    #match one or more characters in match 3 that are NOT 
> in match 2

[^\2] doesn't mean "negate group 2" as you and the manual people seem to 
think. It means "any character except that with ascii code 2".


-- 
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
0
stereofrog (317)
9/7/2007 9:47:58 AM
On Fri, 07 Sep 2007 11:47:58 +0200, gosha bine <stereofrog@gmail.com>  
wrote:

> On 07.09.2007 09:56 Rik Wasmus wrote:
>
>>       ([^\2]+)    #match one or more characters in match 3 that are NOT  
>> in match 2
>
> [^\2] doesn't mean "negate group 2" as you and the manual people seem to  
> think. It means "any character except that with ascii code 2".

Hmmz, a quick check indicates you're right, mea culpa.

The manual iq quite confusing at this point though:
"Inside a character class, or if the decimal number is greater than 9 and  
there have not been that many capturing subpatterns, PCRE re-reads up to  
three octal digits following the backslash, and generates a single byte  
 from the least significant 8 bits of the value. Any subsequent digits  
stand for themselves. For example:
.....
\7
is always a back reference
\11
might be a back reference, or another way of writing a tab"

According to this, I'd expect it to be a back reference. Which brings me  
to the question: what is the way to get a beckreference into a negated  
character class, if there is one?

-- 
Rik Wasmus
0
9/7/2007 12:55:58 PM
On 07.09.2007 14:55 Rik Wasmus wrote:
> On Fri, 07 Sep 2007 11:47:58 +0200, gosha bine <stereofrog@gmail.com> 
> wrote:
> 
>> On 07.09.2007 09:56 Rik Wasmus wrote:
>>
>>>       ([^\2]+)    #match one or more characters in match 3 that are 
>>> NOT in match 2
>>
>> [^\2] doesn't mean "negate group 2" as you and the manual people seem 
>> to think. It means "any character except that with ascii code 2".
> 
> Hmmz, a quick check indicates you're right, mea culpa.
> 
> The manual iq quite confusing at this point though:
> "Inside a character class, or if the decimal number is greater than 9 
> and there have not been that many capturing subpatterns, PCRE re-reads 
> up to three octal digits following the backslash, and generates a single 
> byte from the least significant 8 bits of the value. Any subsequent 
> digits stand for themselves. For example:
> ....
> \7
> is always a back reference
> \11
> might be a back reference, or another way of writing a tab"

Well, it's clear enough: "Inside a character class..."

> 
> According to this, I'd expect it to be a back reference. Which brings me 
> to the question: what is the way to get a beckreference into a negated 
> character class, if there is one?
> 

Character classes are... hm... classes of _characters_, there's no way 
to put references (which are _strings_) there.



-- 
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
0
stereofrog (317)
9/7/2007 1:07:52 PM
On Fri, 07 Sep 2007 15:07:52 +0200, gosha bine <stereofrog@gmail.com>  =

wrote:

> On 07.09.2007 14:55 Rik Wasmus wrote:
>> On Fri, 07 Sep 2007 11:47:58 +0200, gosha bine <stereofrog@gmail.com>=
  =

>> wrote:
>>
>>> On 07.09.2007 09:56 Rik Wasmus wrote:
>>>
>>>>       ([^\2]+)    #match one or more characters in match 3 that are=
  =

>>>> NOT in match 2
>>>
>>> [^\2] doesn't mean "negate group 2" as you and the manual people see=
m  =

>>> to think. It means "any character except that with ascii code 2".
>>  Hmmz, a quick check indicates you're right, mea culpa.
>>  The manual iq quite confusing at this point though:
>> "Inside a character class, or if the decimal number is greater than 9=
  =

>> and there have not been that many capturing subpatterns, PCRE re-read=
s  =

>> up to three octal digits following the backslash, and generates a  =

>> single byte from the least significant 8 bits of the value. Any  =

>> subsequent digits stand for themselves. For example:
>> ....
>> \7
>> is always a back reference
>> \11
>> might be a back reference, or another way of writing a tab"
>
> Well, it's clear enough: "Inside a character class..."

Yes it states "inside a character class IF THE NUMBER IS GREATER THEN 9"=

And continues on saying that inside a character class \7 should still be=
 a  =

backreference..

>>  According to this, I'd expect it to be a back reference. Which bring=
s  =

>> me to the question: what is the way to get a beckreference into a  =

>> negated character class, if there is one?
>>
>
> Character classes are... hm... classes of _characters_, there's no way=
  =

> to put references (which are _strings_) there.

Allthough single characters can, and that's all we're after, we're not  =

matching 'a specific string' just 'not any collection of characters', bu=
t  =

I see your point. It should be done with something like '/=3D(\'|").*?\1=
/',  =

allthough escaped (by \) quoting characters require some more care (alwa=
ys  =

'ignore' a single character after '\')
-- =

Rik Wasmus
0
9/7/2007 1:29:38 PM
On 07.09.2007 15:29 Rik Wasmus wrote:
> On Fri, 07 Sep 2007 15:07:52 +0200, gosha bine <stereofrog@gmail.com> 
> wrote:
> 
>> On 07.09.2007 14:55 Rik Wasmus wrote:
>>> On Fri, 07 Sep 2007 11:47:58 +0200, gosha bine <stereofrog@gmail.com> 
>>> wrote:
>>>
>>>> On 07.09.2007 09:56 Rik Wasmus wrote:
>>>>
>>>>>       ([^\2]+)    #match one or more characters in match 3 that are 
>>>>> NOT in match 2
>>>>
>>>> [^\2] doesn't mean "negate group 2" as you and the manual people 
>>>> seem to think. It means "any character except that with ascii code 2".
>>>  Hmmz, a quick check indicates you're right, mea culpa.
>>>  The manual iq quite confusing at this point though:
>>> "Inside a character class, or if the decimal number is greater than 9 
>>> and there have not been that many capturing subpatterns, PCRE 
>>> re-reads up to three octal digits following the backslash, and 
>>> generates a single byte from the least significant 8 bits of the 
>>> value. Any subsequent digits stand for themselves. For example:
>>> ....
>>> \7
>>> is always a back reference
>>> \11
>>> might be a back reference, or another way of writing a tab"
>>
>> Well, it's clear enough: "Inside a character class..."
> 
> Yes it states "inside a character class IF THE NUMBER IS GREATER THEN 9"
> And continues on saying that inside a character class \7 should still be 
> a backreference..

No, just read it again. "Inside a character class OR if the decimal 
number etc". Can everybody see OR?   ;)))

The wording is unambiguous, but I agree it might be confusing.

> 
>>>  According to this, I'd expect it to be a back reference. Which 
>>> brings me to the question: what is the way to get a beckreference 
>>> into a negated character class, if there is one?
>>>
>>
>> Character classes are... hm... classes of _characters_, there's no way 
>> to put references (which are _strings_) there.
> 
> Allthough single characters can, and that's all we're after, we're not 
> matching 'a specific string' just 'not any collection of characters', 
> but I see your point. It should be done with something like 
> '/=(\'|").*?\1/', allthough escaped (by \) quoting characters require 
> some more care (always 'ignore' a single character after '\')

I'd use the class for quotes (\\w+)=([\'"])(.*?)\\1

As for escaping, it's practical not to rely on (fuzzy) php escaping 
rules and to double every pcre-specific slash.

-- 
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
0
stereofrog (317)
9/7/2007 2:03:47 PM
gosha bine <stereofrog@gmail.com> wrote in news:46e11e53$0$31118
$6e1ede2f@read.cnntp.org:

> On 07.09.2007 09:56 Rik Wasmus wrote:
> 
>>       ([^\2]+)    #match one or more characters in match 3 that are NOT 
>> in match 2
> 
> [^\2] doesn't mean "negate group 2" as you and the manual people seem to 
> think. It means "any character except that with ascii code 2".

Thanks for your help, guys.

This seems strange to me though, why bother matching anything but STX?  Is 
STX actually used by anything anywhere?  Googling seems to indicate that 
this is something that printers use, not very useful when parsing HTTP.

-- 
Posted via a free Usenet account from http://www.teranews.com

0
9/8/2007 1:53:50 AM
"Rik Wasmus" <luiheidsgoeroe@hotmail.com> wrote in
news:op.tx9xnong5bnjuv@metallium.lan: 
> On Fri, 07 Sep 2007 08:02:07 +0200, Zenofobe
> <fake_email@fake_domain.com>  
> 
> wrote:
> 
>> Howdy folks,
>>
>> On this page at php.net
>>          http://www.php.net/features.http-auth
>> there's a regular expression in Example 34.2.  It's supposed to parse
> out
>> the different values being passed in the header.  I know what it's
>> supposed to do, so I have a vague idea of what's being done in the
>> RE, 
>> but I've been having a heck of a time figuring out what each part of
>> the
>> RE is actually doing.  Here's what I have so far:
>>
>> preg_match_all('@(\w+)=(?:([\'"])([^\2]+)\2|([^\s,]+))@', $txt, $mat
> ches,
>> PREG_SET_ORDER);
>>
>> //'@
>> //(\w+)          Any word character (letter/digit/_), 1 or more
>> //=               Equal sign
>> //(?:                   This submatch will not be captured (still
>> available for later matching)
>> //([\'"])          A single or double quote
>> //([^\2]+)              Not start of text (STX)?, 1 or more
>> //\2|
>> //([^\s,]+)              Not whitespace or comma, 1 or more
>> //)
>> //@'
> 
> Quick tip for starting with regexes: use the x modifier, so you can  
> comment this is in the regex itself for later.
> 
> preg_match_all('@ #starting delimiter
>       (\w+)        #any word character (one er more) in match 1
>       =            #literal '='
>      (?:           #start of non-capturing subpattern
>        ([\'"])     #either \' or " in match 2
>        ([^\2]+)    #match one or more characters in match 3 that are
>        NOT in  
> match 2
>        \2          #match the same character as matched in 2
>        |           #or
>        ([^\s,]+)   #character not whitespace or comma in match 4
>      )             #end of non-capturing subpattern
>      @             #ending delimiter
> x', $txt, $matches,PREG_SET_ORDER);
> 
>> I'm unclear as to what the second \2 does,
> 
> It's a 'reference' to the match allready captured in match 2
> 
>> as well as which parts the OR
>> applies to.
> 
> The pattern seems to try to capture name/value pairs, where either the
>  value is quoted with a ' or ", or consist of "characters not
> whitespace or  comma". So it will match "foo='bar'" & "foo=bar", but
> in "foo=bar baz"  still only 'bar' will be matched in 4, not 'bar
> baz'. 

So in other words the OR selects between

    	([\'"])([^\2]+)\2

and

    	([^\s,]+).


Correct?  In other words, it binds least strongly in comparison with all 
the other operators.

-- 
Posted via a free Usenet account from http://www.teranews.com

0
9/8/2007 1:57:40 AM
Zenofobe wrote:
> gosha bine <stereofrog@gmail.com> wrote in news:46e11e53$0$31118
> $6e1ede2f@read.cnntp.org:
> 
>> On 07.09.2007 09:56 Rik Wasmus wrote:
>>
>>>       ([^\2]+)    #match one or more characters in match 3 that are NOT 
>>> in match 2
>> [^\2] doesn't mean "negate group 2" as you and the manual people seem to 
>> think. It means "any character except that with ascii code 2".
> 
> Thanks for your help, guys.
> 
> This seems strange to me though, why bother matching anything but STX?  Is 
> STX actually used by anything anywhere?  Googling seems to indicate that 
> this is something that printers use, not very useful when parsing HTTP.
> 

It's used in the very lowest level of many protocols, but by the time 
you see it, the STX and related control characters have been stripped.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
jstucklex (14659)
9/8/2007 3:41:37 AM
Reply:

Similar Artilces:

PHP regular expressions
Hello, I am writing an elearning software with php. I need a script to recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on. Could anyone tell me how can I do this using regular expressions? Regards, Albert Achtenberg Albert <albert@arbel-designs.com> wrote: > I am writing an elearning software with php. I need a script to > recognize any inut of the type ab,aabb,aaabbb,aaaabbbb..... And so on. > Could anyone tell me how can I do this using regular expressions? So basically you need a regexp tutorial. I don't know any but studing http://nl.php.net/manual...

PHP Training Institute In Delhi, Live Projects on PHP. Short Term PHP Courses, PHP Scripts, PHP Training with Live Projects.
Vserve Global offers short term PHP: Hypertext Preprocessor Training Course, which is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web page content from it. It can be deployed on most web servers and on almost every operating system and platform free of charge.PHP is installed on over 20 million websites and 1 million web servers. TOPICS:- >> Core PHP Language >> HTML, Cascad...

php to php obj
Hi All, Is there any tool to convert the .php files into its object files in deploying the files to other's server like java classes are deployed? Thanks in advance --AR John7481 <arjohn7481@hotmail.com> wrote or quoted: > Is there any tool to convert the .php files into its object files in > deploying the files to other's server like java classes are deployed? To what end? Do you want a PHP obfuscator? They tend not to be needed - since the code remains on the server. Do you want a PHP squeezer? Again - since PHP remains on the server that is of reduced importance. PHP obfuscators and squeezers are out there - but what exactly are you looking for? -- __________ |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply. With total disregard for any kind of safety measures Tim Tyler <tim@tt1lock.org> leapt forth and uttered: > John7481 <arjohn7481@hotmail.com> wrote or quoted: > >> Is there any tool to convert the .php files into its object >> files in deploying the files to other's server like java >> classes are deployed? > > To what end? > > Do you want a PHP obfuscator? They tend not to be needed - > since the code remains on the server. > > Do you want a PHP squeezer? Again - since PHP remains on the > server that is of reduced importance. > > PHP obfuscators and squeezers are out there - but what exactly > are you looking for? I think he'...

Question on PHP regular expressions
In PHP I have many more options for functions that do regular expression than I did in Perl. My question is what is the best one to use for doing the following: Give the following: {Somestring.somestring.somestring} blah blah {somestring} value here not used {more.text.here} I want an array like the following: [0] => Somestring.somestring.somestring [1] => somestring [2] => more.text.here So basically I just want to capture the contents (alpha-numeric + periods) inside of curly braces. Thanks for any help. sberry <sean@buildingonline.com> writes: > In PHP I have many more options for functions that do regular > expression than I did in Perl. My question is what is the best one to > use for doing the following: > > Give the following: > {Somestring.somestring.somestring} blah blah {somestring} value here > not used {more.text.here} > > I want an array like the following: > [0] => Somestring.somestring.somestring > [1] => somestring > [2] => more.text.here > > So basically I just want to capture the contents (alpha-numeric + > periods) inside of curly braces. > > Thanks for any help. This should get you started: $string = "{Somestring.somestring.somestring} blah blah {somestring} value here not used {more.text.here}"; $pattern = '/\{.+?\}/'; preg_match_all($pattern, $string, $matches); print_r($matches); Hope that helps, On Nov 8, 11:17 am, Carl <c.gro...@gmail.com>...

PHP within PHP...
I took over the support of a website that is set up something like this inside one of the pages: include_once("header.php"); <?php //to get the content of the page they do this: $content = mysql_query("select content etc...); echo $content; ?> include_once("footer.php"); I am having problems evaluating any php that is used in the mysql content. Is there a way to get the mysql withing the mysql to run? Thank you for your time, Mandragon On Sep 17, 12:56 pm, Mandrago...@gmail.com wrote: > I took over the support of a website that is set up something like > this inside one of the pages: > > include_once("header.php"); > > <?php > //to get the content of the page they do this: > $content = mysql_query("select content etc...); > > echo $content; > ?> > > include_once("footer.php"); > > I am having problems evaluating any php that is used in the mysql > content. Is there a way to get the mysql withing the mysql to run? > > Thank you for your time, > > Mandragon Sorry, The question should read: "Is there a way to get the php withing the echo $htmlcontent to run?" Of course you are, $content is a resource. The MySQL Query resource. try this: $content = mysql_query('bla bla bla'); while ($row = mysql_fetch_assoc($content)) { $result[] = $row; } $content = $result; Now you can use $content ;). In answer to your edit... eval($co...

php outside php (?)
Sounds weird, i know. What i want/wonder is the following: PHP can do the next: <?php if($foo == 'bar') { ?> Ow yeah, foo is bar! <?php }; ?> But how can i do the following: <?php $foo= ?> this is what foo looks like. <?php }; ?> This way i could edit the content of $foo in DW's design-view. I hope it's clear enough for you all to understand... Greetings frizzle. frizzle wrote: > But how can i do the following: > > <?php > > $foo= > > ?> > this is what foo looks like. > <?php > > }; > > ?> > > This way i could edit the content of $foo in DW's design-view. > I hope it's clear enough for you all to understand... <?php ob_start(); ?> this is what foo looks like. <?php $foo=ob_get_clean(); ?> -- Justin Koivisto - justin@koivi.com http://koivi.com Wow, little late on the reply, but i still wanted to thank you for your help. This is exactly what i meant, and it works great! :D Thanks again. ...

Converting PERL regular expression to PHP?
Hi, I'm in the process of converting some PERL to PHP. Thus, is it possible to leave the following line as is: if ($id =~ /vvvvv/g) { ... } If not, can someone provide PHP equivalent? BTW, I have checked the syntax using 'php -l' because I'm not an expert of PERL but I'm using various references to do the conversion. However, I was able to locate this particular construct. Thanks in advance, -Conrad Hi, the last couple of sentences should read: If not, can someone provide PHP equivalent? BTW, I have checked the syntax using 'php -l'. Also, I'...

Anyone here follows the mailing list php-general@lists.php.net?
I tried posting to it (I am subscribed and have posted to it successfully before, but this time I got this error message: >> This message was created automatically by mail delivery software. >> >> A message that you sent could not be delivered to one or more of its >> recipients. This is a permanent error. The following address(es) >> failed: >> >> php-general@lists.php.net >> SMTP error from remote mail server after end of data: >> host pair1.php.net [76.75.200.58]: 550 we're manly enough already WTH...

Regular Expression for replacing images through URLs in PHP
Hi! I want to replace images through URLs with the help of a regular expression. For example: <img src='http://xxxxx.net/photo/small.jpg'> should be replaced through: <a href='http://xxxxx.net/photo/small.jpg'>Link</a> Another problem are emoticons, which are also included as <img>. Therefore I would like to extend the upper regular expression that the image should only be replaced through an URL, if the src attribute of the img tag does not start with "/modules/emoticons/". Thanks in advance, Markus On Tue, 19 Jul 2005 10:31:30 +02...

Best PHP Training | PHP Development Training | PHP Training Institute
Tops Technologies provides php and mysql certification courses in ahmedabad, baroda, surat, Rajkot, Udaipur, Gujarat, india.PHP Training with MySQL is an introductory course in the PHP and MySQL technology. Mysql and php training course, php for beginners, sql training courses, PHP Training courses, php courses, mysql training courses, php mysql course. For More Details :- http://www.tops-int.com ...

http://us.php.net/manual/en/ref.pdo.php $dbh = null;
The above page presents the following information... Example 1695. Handling connection errors <?php $DBName = "sqlite:db.sq3"; $user = "admin"; $pass = "admin"; try { $dbh = new PDO($DBName, $user, $pass); $dbh->exec('CREATE TABLE FOO(id INDEX PRIMARY KEY, name TEXT);'); $dbh = null; // Error or warning. This is the only line I didn't change. } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } ?> The $dbh = null; line coughs up an error. That's one of the only lines ...

php regular expression doesn't match
Hi PHP's regular expression look like doesn't support .*? syntax. So i cannot match the shortest match. For exmaple: $str="a1b a3b"; $str1=ereg_replace("a.*b", "peter", $str1); will produce "peter", but i want "peter peter", so how to? thanks from Peter (cmk128@hotmail.com) cmk128@hotmail.com wrote: > Hi Hi, > PHP's regular expression look like doesn't support .*? syntax. So i > cannot match the shortest match. For exmaple: > > $str="a1b a3b"; Typo. That was $str1="a1b a3b" I expect. > $str1=ereg_replace("a.*b", "peter", $str1); > will produce "peter", but i want "peter peter", so how to? > Yes, * is greedy. I do not know your real-world example, but maybe using a wordboundary can solve your problem? eg: $str1=ereg_replace("/a.*b\b/", "peter", $str1); > thanks > from Peter (cmk128@hotmail.com) > Regards, Erwin Moller Erwin Moller wrote: > cmk128@hotmail.com wrote: >> Hi > > Hi, > >> PHP's regular expression look like doesn't support .*? syntax. So i >> cannot match the shortest match. For exmaple: >> >> $str="a1b a3b"; > > Typo. That was $str1="a1b a3b" I expect. > >> $str1=ereg_replace("a.*b", "peter", $str1); >> will produce "peter", but i want "p...

the mail() example on www.php.net seems to be broken
I needed a simple way to send out some mail, so I went to www.php.net and copied their example code: http://us3.php.net/manual/en/function.mail.php The form I used to compose the email was different from the php.net example, but in terms of formatting the headers, the code is nearly identical: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: $returnAddress \r\n" ; $success = mail($thisEmail, $emailSubject, $emailMainContent, $headers); I sent this out. But several...

Send array from php to php
HI every one I' try to send array from web page to php file but no data are show I'm using session to store data and this is my code //////////////////////////////////////////////////////////////////////// $data = $cart_items; session_register('data'); foreach ($cart_items as $cart_item) { echo "<tr>"; echo " <td><span class='style2'>".$cart_item->name."</span></td>"; echo " <td><span class='style2'>".$cart_item->description."</ span></td>"; echo " <td><span class='style2'>".$cart_item->price." S.R.</span></ td>"; echo " <td><span class='style2'>".$cart_item->quantity."</span></ td>"; echo " <td><span class='style2'>".$cart_item->price * $cart_item- >quantity."</span></td>"; echo " <td><span class='style4'><a href='order.php?action=del&id=". $cart_item->object_id."'>[del]</a></span></td>"; echo "</tr>"; \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ and this is my php code to get the data //////////////////////////////////////////////////////// <?php foreach ($data as $item) { echo "<tr>"; print " &l...

PHP does not parse .PHP files
I have this problem with PHP that someone might be able to help. With CLI, I am able to execute my .php files. For example, if I type "php phpinfo.php" , this works fine on my system. If I put the phpinfo.php file is in /var/www/html and I try to access it through the browser, I get the content of the file and not the execution of the file. Instead of display the info of PHP, I got the text of the file as: <?php phpinfo(); ?> Why? Thanks Phong Ho wrote: >I have this problem with PHP that someone might be able to help. > >With CLI, I am able to execute my ....

PHP with Indian PHP Developers
Dear all, If you want to make a PHP web application, or need to <a href="http:// www.virtueinfo.com/php-developers/hire-php-programmers-developers-india.htm">Hire PHP Developer</a>contact a leading <a href="http://www.virtueinfo.com/ php-developers/php-web-development.htm"> PHP Web Development Compnay</ a> <a href="http://www.virtueinfo.com/php-developers/php-web-programming- php-developers-india.htm">Offshore PHP web development India</a> On Thu, 25 Feb 2010 01:37:02 -0800 (PST), Virtue Info wrote: > Dear all, > > > If you want to make a PHP web application, or need to <a href="http:// > www.example.com/php-developers/hire-php-programmers-developers-india.htm">Hire > PHP Developer</a>contact a leading <a href="http://www.example.com/ > php-developers/php-web-development.htm"> PHP Web Development Compnay</ > a> > > ><a href="http://www.example.com/php-developers/php-web-programming- > php-developers-india.htm">Offshore PHP web development India</a> > Third time's the charm? Not exactly a ringing endorsement of the skills you've got available or your testing method reliablity... -- 12. One of my advisors will be an average five-year-old child. Any flaws in my plan that he is able to spot will be corrected before implementation. --Peter Anspach's list of things to do as an ...

php://memory and php://temp
http://php.net/manual/en/wrappers.php.php per the documentation: php://memory and php://temp are both listed under "Allows Appending" what am I missing / what's the point? They only seem to work with read/write modes such as fopen('php://memory','rw'); closing the handle, or trying to open another handle without closing the first essentially erase the contents... so what's the point of fopen('php://memory','a') ? you'll a) be appending nothing, b) no way to read what you just wrote? sure would be nice if you could $fh = fopen('php://memory', 'w'); fwrite($fh, 'test string'); fclose($fh); $fh = fopen('php://memory', 'r'); $result = fgets($fh,2048); fclose($fh); echo $result; On 10/12/2010 9:44 PM, BKDotCom wrote: > http://php.net/manual/en/wrappers.php.php > per the documentation: php://memory and php://temp are both listed > under "Allows Appending" > > what am I missing / what's the point? > > They only seem to work with read/write modes such as > fopen('php://memory','rw'); > > closing the handle, or trying to open another handle without closing > the first essentially erase the contents... so what's the point of > fopen('php://memory','a') ? > you'll > a) be appending nothing, > b) no way to read what you just wrote? > > sure would be nice if you could > > $fh = ...

Php constants in php.ini
I am trying to set user_agent = PHP_VERSION in php.ini. In my php.ini the instructions say that you can use constants in the php.ini file. The only constants I can get to work, though, are the error level constants like E_ALL, E_ERROR, E_WARNING, etc., ... Is anyone aware of some sort of trick to getting others to work? (I was thinking it would be nice to have the user agent string used by my Php scripts to use PHP_VERSION in the string.) -- ***************************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Integrity is obvious. The lack of it is common. *****...

PHP EXAMPLE
Good Morning ! There are any site's of example programming php Bye Max massimo.piratti@gmail.com wrote: > Good Morning ! > There are any site's of example programming php > > Bye Max http://www.pixel2life.com/tutorials/php_coding/ http://en.wikipedia.org/wiki/PHP http://www.google.com/search?hl=en&lr=&q=programming+php+free+example&btnG=Search www.w3schools.com Extensive Topic List HTML Tutorials Learn HTML Learn XHTML Learn CSS Learn TCP/IP XML Tutorials Learn XML Learn XSL Learn XSLT Learn XSL-FO Learn XPath Learn XQuery Learn XLink Learn XPointer Le...

about php lang
plz told me that what is the php lang., how does it works and where it used. mani <msb.jod@gmail.com> wrote: > plz told me that what is the php lang., how does it works and where it > used. There is a good explanation at http://lmgtfy.com/?q=php regards Henrik -- The address in the header is only to prevent spam. My real address is: hc3(at)poolhem.se Examples of addresses which go to spammers: root@localhost postmaster@localhost On 16 Jun 2009, mani <msb.jod@gmail.com> wrote: > plz told me that what is the php lang., how does it works and > where it used. Lulz. <http://www.google.com/> -- ~Curtis Anonymous (1984 IOCCC winner): int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\ o, world!\n",'/'/'/'));}read(j,i,p){write(j/p+p,i---j,i/i);} mani schreef: > plz told me that what is the php lang., how does it works and where it > used. http://en.wikipedia.org/wiki/Php Tip: If you want to learn something about a subject totally new to you, try wikipedia for a reasonable intro. Regards, Erwin Moller -- "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." -- C.A.R. Hoare ...

PHP and .NET
Before I begin let me thank the many people in this group who have helped me over the last few years. It has been greatly appreciated. For the last several years I have been coding all server code in php. I love the language. However, I live in an area (in the midlle of a triangle formed by Orlando, Tampa and Gainesville) that seems to have companies that use .NET and asp. I have done no work in these, so I have to learn them quickly so that I can get a job/contract. I have found a great site called www.w3schools.com, and am looking there to study aspx (asp with .net). I have even installed IIS on my machine so that I can proceed. I still use Dreamweaver as my editor/syntax indicator. Does anyone have any suggestions as to the best way to proceed, great tutorials other than this one, and a news group for aspx that is as good as this one is for php? Thanks. -- Shelly Sheldon Glickler wrote: > Before I begin let me thank the many people in this group who have helped me > over the last few years. It has been greatly appreciated. > > For the last several years I have been coding all server code in php. I > love the language. However, I live in an area (in the midlle of a triangle > formed by Orlando, Tampa and Gainesville) that seems to have companies that > use .NET and asp. I have done no work in these, so I have to learn them > quickly so that I can get a job/contract. > > I have found a great site called www....

Does PHP need the .php extension ?
Hi guys, When I use PHP I give my file the .php extension. I always wondered if it could be an .htm page with a <script> block that the PHP resides in, the same way you would do JavaScript. If you can do it that way are there any benifits to that method ? Take care, Cyrus "Cyrus D." <satan@invalid.org> writes: > Hi guys, > > When I use PHP I give my file the .php extension. I always wondered if it > could be an .htm page with a <script> block that the PHP resides in, the > same way you would do JavaScript. If you can do it that way are the...

php notification through php sdk
Hi there I want to build a e-commerce website similar to wish.com and I have chosen opencast as my framework of choice. Now wish has a feature that when you save a product in wish and if you are logged in with Facebook or gmail all of your friends will get a notification that your friends has saved a item on wish. I want a similar feature on my site Now I know Facebook provide a sdk JavaScript and php and wish might be using something similar but I am using open cart can I open home page or product page in the sdk Thanks On 3/20/2015 7:30 AM, apoorv.kanungo@gmail.com wrote: &g...

why does $_SERVER['PHP_SELF'] say /test.php/test.php for test.php?
I have a PHP script at 127.0.0.1/test.php. It's contents are as follows: <?php echo $_SERVER['PHP_SELF']; ?> And it's output isn't test.php, as I'd expect, or /test.php, but rather, /test.php/test.php. Why? And how do I fix it? El 06/10/2010 6:53, yawnmoth escribi�/wrote: > I have a PHP script at 127.0.0.1/test.php. It's contents are as > follows: > > <?php > echo $_SERVER['PHP_SELF']; > ?> > > And it's output isn't test.php, as I'd expect, or /test.php, but > rather, /test.php/test.php. Why? And how do I fix it? What output do you get if you change it to this? <?php echo '[' . $_SERVER['PHP_SELF'] . ']'; ?> What do your other $_SERVER values look like? <?php print_r($_SERVER); ?> -- -- http://alvaro.es - �lvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programaci�n web: http://borrame.com -- Mi web de humor satinado: http://www.demogracia.com -- On 06/10/10 09:30, "�lvaro G. Vicario" wrote: > El 06/10/2010 6:53, yawnmoth escribi�/wrote: >> I have a PHP script at 127.0.0.1/test.php. It's contents are as >> follows: >> >> <?php >> echo $_SERVER['PHP_SELF']; >> ?> >> >> And it's output isn't test.php, as I'd expect, or /test.php, but >> rather, /test.php/test.php. Why? And how do I fix it? > > What output do you get if you change it ...

Web resources about - Regular expression example on PHP.net - comp.lang.php

Expression (mathematics) - Wikipedia, the free encyclopedia
In mathematics, an expression is a finite combination of symbols that is well-formed according to rules that depend on the context. Symbols can ...

Arab women artists and their long road to expression
At a London festival, female artists grapple with the issues facing their region and their own identities.

Christie’s Expressions At Trump Event Under Scrutiny
Donald Trump Holds Super Tuesday Election Night Press Conf. In Palm Beach PALM BEACH, FL - MARCH 01: Republican Presidential frontrunner Donald ...

Decoding The Facial Expressions Of The GOP Candidates
Trump's "crooked contemptuous" smile, Rubio's sheepish grin, and Cruz's upper lip of disgust dominated the debate. For tonight's Republican ...

You enjoy freedom of expression only because army guards borders: Delhi HC to Kanhaiya Kumar
The bail granted to Kanhaiya Kumar comes with several conditions, directives to JNU faculty and some serious observations

Bernie Sanders Brought His Finest Facial Expressions to the Democratic Debate
You may not like Bernie Sanders as a presidential candidate, but you’ve gotta admit, this man’s got some pretty expressive peepers. Read more... ...

Crosswords Help You Learn Regular Expressions
Regular expressions might seem arcane, but if you do any kind of software, they are a powerful hacker tool. Obviously, if you are writing software ...

Security, the Greatest Threat to Free Expression?
Like it or not, today we are all, in one way or another, engaged in a battle between perceived security and freedom of expression. And far too ...

'Animal Soul' Book Of Photos: Expression in Cats and Dogs
Intrigued by the facial expressions of dogs and cats, photographer Robert Bahou is compiling a book of his efforts to capture them.

It Turns Out Vanessa Hudgens' Expression of Love Was Highly Illegal
The Federal Government cares more about some old, dead, scratched up rocks in the desert than it cares about Vanessa Hudgens and Austin Butler ...

Resources last updated: 3/23/2016 7:36:51 PM