0

with php8 I am now getting warnings on if statements with my variables.

Current if ($var): echo $var; endif;

Updated Format if (isset($var)): echo $var; endif;

I am looking for a regex expression to wrap all instances of if ($var) and if($var) to if (isset($var). the $var is not always var obviously so I think this could be accomplished with regex . Thanks!

replace: if \(\$(.*)\) with: if (isset($$$1))

This almost works but it wraps the entire if-statement if it begins with a $.

Rocco
  • 471
  • 1
  • 3
  • 7
  • Try `\w+` instead of `.*`, to capture single words – aynber Feb 01 '23 at 15:44
  • 1
    Why would the entire `if` statement begin with `$`? You can't write `$if`. Can you show an example of the incorrect replacement? – Barmar Feb 01 '23 at 15:57
  • Using \w+ worked! thanks. Barmar - when i say the If statement begins with $ I mean inside the parentheses. ie: if ($var == 0 && $var == 3). That would be an example of ones I would not want to target – antennaRichard Feb 01 '23 at 16:10

0 Answers0