Skip to content

Instantly share code, notes, and snippets.

@LinuxDoku
Created August 16, 2013 12:57
Show Gist options
  • Save LinuxDoku/6249742 to your computer and use it in GitHub Desktop.
Save LinuxDoku/6249742 to your computer and use it in GitHub Desktop.
markup filter regex for variable assignment inside if()
if[ \n]*\([0]*[^ ]*\$[a-z0-9-_]+[ ]*=[^=]+[ ]*[^ ]+[ ]*\)
<?php
if($a = 'test') // true
if($a='Test') // true
if($a="Test") // true
if($a = "Test") // true
if ($a = 'Test' ) // true
if
($a = "Hallo Welt") // true
if($a == 'test')
if(test::$a = "Hallo Welt") // true
if(($a = "Test")) // true
if($a = (2 + 1)) // FAIL
if($a = ($a = 2 + 1)) // FAIL
if($a == "test" && ($a = 2)) // FAIL
// to detect mistakes ;-)
if(test::$a === 'Test')
if($a === "Hallo Welt")
if($a)
$a = "Test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment