Skip to content

Instantly share code, notes, and snippets.

Nikita Popov nikic

View GitHub Profile
@nikic
nikic / gist:4162505
Created Nov 28, 2012
Regex to validate (IPv4) CIDR notation (with capture)
View gist:4162505
\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(3[0-2]|[1-2]?[0-9])\b
\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.((?1))\.((?1))\.((?1))/(3[0-2]|[1-2]?[0-9])\b
@nikic
nikic / gist:1188670
Created Sep 2, 2011 — forked from ircmaxell/gist:1188649
PHP example on variable variables - without needing them
View gist:1188670
<?php
function bar($a, $b, $c) {
foreach (compact('a', 'b', 'c') as $key => $value) {
$form[$key] = array(
'#type' => 'hidden',
'#value' => $value,
);
}
}
View gist:04fce01e69ae5b7b44f8
<?php
require './vendor/autoload.php';
// The code samples to parse.
// => bool(false)
$code = '<?php class Foo {public $bar;}';
// => bool(true)
You can’t perform that action at this time.