473,324 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

unexpected T_DNUMBER = HUH?

Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
.. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]

Bluntly put, I simply don't get it. It's bad enough that the RegExp
fails, but why would it break and why break in such a way that makes no
sense to anyone?

This is all I want to do:

REPLACE

* @version 1.0.0

WITH

* @version 1.1.0

Inside each non-binary file that contains that exact line pattern!

And that's all.

Thanx
Phil

Dec 6 '05 #1
6 14763
>Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]


Probably not the offending line...that didn't give me any syntax
errors. Perhaps the line before?

Dec 6 '05 #2
I wish that were the case. The offensive line number points to that
exact line; the line before it is a single-line PHP comment.

Env: PHP 4.1.2, 4.3.2, 5.0.4

Phil

ZeldorBlat wrote:
Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]


Probably not the offending line...that didn't give me any syntax
errors. Perhaps the line before?


Dec 6 '05 #3
comp.lang.php wrote:
Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]

Bluntly put, I simply don't get it. It's bad enough that the RegExp
fails, but why would it break and why break in such a way that makes no
sense to anyone?

This is all I want to do:

REPLACE

* @version 1.0.0

WITH

* @version 1.1.0

Inside each non-binary file that contains that exact line pattern!

And that's all.

Thanx
Phil


It's the e modifier... because $2 is not a valid variable name in PHP.
Try something a bit simpler:

<?php
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($old_version)).')(.*)$`i';
$contents = preg_replace($pattern,'\\1 '.$new_version,$contents);
?>

That will replace a version number like "1.0.0/rev4" into the new one,
assuming that the line is similar to:

* @version 1.0.0/rev4 - some other note

Of course, whenever you can use a string function over regex, do it:
$content=str_replace($old_version,$new_version,$co ntent);

May not apply in your case, but if it does, it's better.

HTH

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Dec 6 '05 #4
Good News: The T_DNUMBER error is gone, but makes absolutely no sense
why it's gone, you CAN use '$1' - '$9' in regular expressions!

Bad News: The pattern match failed to find the pattern to make the
substitution using your code:

[PHP]
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($oldversion)).')(.*)$`i';
$contents = preg_replace($pattern, '\\1 ' . $newversion,
$contents);
[/PHP]

So it's half fixed :)

Phil

Justin Koivisto wrote:
comp.lang.php wrote:
Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]

Bluntly put, I simply don't get it. It's bad enough that the RegExp
fails, but why would it break and why break in such a way that makes no
sense to anyone?

This is all I want to do:

REPLACE

* @version 1.0.0

WITH

* @version 1.1.0

Inside each non-binary file that contains that exact line pattern!

And that's all.

Thanx
Phil


It's the e modifier... because $2 is not a valid variable name in PHP.
Try something a bit simpler:

<?php
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($old_version)).')(.*)$`i';
$contents = preg_replace($pattern,'\\1 '.$new_version,$contents);
?>

That will replace a version number like "1.0.0/rev4" into the new one,
assuming that the line is similar to:

* @version 1.0.0/rev4 - some other note

Of course, whenever you can use a string function over regex, do it:
$content=str_replace($old_version,$new_version,$co ntent);

May not apply in your case, but if it does, it's better.

HTH

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com


Dec 6 '05 #5
Oh, one more thing: I replaced '\\1 ' with '$1' to prove that that
could not have been the cause of the T_DNUMBER error:

[PHP]
// FIND THE PATTERN OF THE OLD VERSION
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($oldversion)).')(.*)$`i';
$contents = preg_replace($pattern, '$1 ' . $newversion . '$2',
$contents);
[/PHP]

No errors! Even this produced no errors:

[PHP]
$contents = preg_replace('/`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($oldversion)).')(.*)$`/i', '$1 ' .
$newversion . '$2', $contents);
[/PHP]

Like I said, it's half fixed though with your variation of the regular
expression pattern, but now simply failing to match the pattern, but no
errors!

Phil

Justin Koivisto wrote:
comp.lang.php wrote:
Offensive Line:
[PHP]
$contents =
preg_replace('/([\s\t]*\*+[\s\t]*@[vV][eE][rR][sS][iI][oO][nN][\s\t]+)'
. str_replace('/', '\\/', preg_quote($oldversion)) . '([\n\r\s\t]*)/e',
'$1' . $newversion . '$2', $contents);
[/PHP]

Bluntly put, I simply don't get it. It's bad enough that the RegExp
fails, but why would it break and why break in such a way that makes no
sense to anyone?

This is all I want to do:

REPLACE

* @version 1.0.0

WITH

* @version 1.1.0

Inside each non-binary file that contains that exact line pattern!

And that's all.

Thanx
Phil


It's the e modifier... because $2 is not a valid variable name in PHP.
Try something a bit simpler:

<?php
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($old_version)).')(.*)$`i';
$contents = preg_replace($pattern,'\\1 '.$new_version,$contents);
?>

That will replace a version number like "1.0.0/rev4" into the new one,
assuming that the line is similar to:

* @version 1.0.0/rev4 - some other note

Of course, whenever you can use a string function over regex, do it:
$content=str_replace($old_version,$new_version,$co ntent);

May not apply in your case, but if it does, it's better.

HTH

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com


Dec 6 '05 #6
comp.lang.php wrote:
Oh, one more thing: I replaced '\\1 ' with '$1' to prove that that
could not have been the cause of the T_DNUMBER error:

[PHP]
// FIND THE PATTERN OF THE OLD VERSION
$pattern='`^(\s*\*\s+\@version)\s*('.
str_replace('/','\\/',preg_quote($oldversion)).')(.*)$`i';
$contents = preg_replace($pattern, '$1 ' . $newversion . '$2',
$contents);
[/PHP]

No errors! Even this produced no errors:

Justin told you the answer to that: the /e qualifier (that you're no
longer using). That qualifier means 'treat the pattern as a PHP
expression, and evaluate it'.

Colin
Dec 7 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version...
1
by: Ken | last post by:
Any thoughts on making explicit calls to unexpected()? My sense is that this function is really intended to be invoked automatically as part of exception handling. Are there times when explicit...
3
by: Teddy | last post by:
Hello all According to "Think in C++ Volume2", the code below should run smoothly: #include <iostream> #include <exception> using namespace std; class ex { };
2
by: Gerhard Esterhuizen | last post by:
Hi, I am observing unexpected behaviour, in the form of a corrupted class member access, from a simple C++ program that accesses an attribute declared in a virtual base class via a chain of...
3
by: Eric Anderson Vianet SAO | last post by:
hello all When i tried ´pg_dump -v -f dump.dmp dtbtransporte´ I got the error: pg_dump: restoring data for table tbdmovimento pg_dump: dumping out the contents of table tbdmovimento ...
5
by: Vijayakrishna Pondala | last post by:
Hi, We are using the following error randomly, when accessing a webservice method/servlet hosted on JBoss application server: The underlying connection was closed: An unexpected error occurred...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
13
by: bintom | last post by:
I ran the following simple code in C++ and got unexpected results: float f = 139.4; cout << f; Output: 139.399994;
10
by: RSchrand | last post by:
First, I am stuck using GoDaddy because that's who my client went with. I'm almost thinking this is related to their address for the database hosting, but I would like confirmation on that. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.