Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Mod Removes Wiki by Doorknob
added 234 characters in body
Source Link
Iszi
  • 2.6k
  • 25
  • 26

IfEncapsulating the command that defines a variable in parenthesis allows you needto feed the variable's definition directly to other commands.

For example, you can set a variable that's$x and then set $y based on the value of another variable, consider setting them both at once.$x in one shot with this:

$y=($x=1)+1

ExampleInstead of this:

$x=1;$y=$x+1

$y=($x=1)+1 You can set $h and output it with this:

($h='Hello World!')

insteadInstead of this:

$x=1;$y=$x+1

$h='Hello World!';$h

If you need to set a variable that's based on the value of another variable, consider setting them both at once.

Example:

$y=($x=1)+1

instead of

$x=1;$y=$x+1

Encapsulating the command that defines a variable in parenthesis allows you to feed the variable's definition directly to other commands.

For example, you can set $x and then set $y based on the value of $x in one shot with this:

$y=($x=1)+1

Instead of this:

$x=1;$y=$x+1

You can set $h and output it with this:

($h='Hello World!')

Instead of this:

$h='Hello World!';$h
Source Link
Iszi
  • 2.6k
  • 25
  • 26

If you need to set a variable that's based on the value of another variable, consider setting them both at once.

Example:

$y=($x=1)+1

instead of

$x=1;$y=$x+1