Increment Behavior on Strings - PHP Easter Egg

Increment behavior on strings - PHP easter egg?

PHP follows Perl's convention when dealing with arithmetic operations
on character variables and not C's. For example, in PHP and Perl $a =
'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into
'[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that
character variables can be incremented but not decremented and even so
only plain ASCII characters (a-z and A-Z) are supported.
Incrementing/decrementing other character variables has no effect, the
original string is unchanged.

-> http://php.net/manual/en/language.operators.increment.php

PHP Increase string value

you can try this regular expression. This snippet works and it gave me result as someString_2

 $string = "someString_1";
function increment($matches) {
return ++$matches[1];
}

echo $string = preg_replace_callback( "|(\d+)|", "increment", $string);

PHP Echo char variable mistake

Take a look at what PHP documentation says about incrementing characters:

PHP follows Perl's convention when dealing with arithmetic operations
on character variables and not C's. For example, in PHP and Perl $a =
'Z'; $a++; turns $a into 'AA', while in C a = 'Z'; a++; turns a into
'[' (ASCII value of 'Z' is 90, ASCII value of '[' is 91). Note that
character variables can be incremented but not decremented and even so
only plain ASCII characters (a-z and A-Z) are supported.
Incrementing/decrementing other character variables has no effect, the
original string is unchanged.

How can I disable PHP's easter egg URLs?

A quick HTACCESS global rewrite could regex the exact string right out of every URL thus getting rid of the only fun part of PHP without touching the ini file nor needing a function at the beginning of every file.

Haven't tested this yet, but this should work:

RewriteEngine On
RewriteCond %{QUERY_STRING} \PHPE9568F36-D428-11d2-A769-00AA001ACF42\ [NC]
RewriteRule .* - [F]

Of course, just copy the last 2 lines for each of the other possible queries, or write a more generic regex. I'm not good with regex. :)

This version covers all of the easter egg fun and was found here:

RewriteEngine On
RewriteCond %{QUERY_STRING} \=PHP[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12} [NC]
RewriteRule .* - [F]

How to display reporting services record set in a collection of textboxes

I found it

right click the textbox
select expressions
select dataset
select your dataset
select First([fieldname])

voila



Related Topics



Leave a reply



Submit