-1

This is sort of a general programming question. However, realizing that the IF conditional is used in many languages, keep in mind I primarily use PHP.

And in PHP, if statements look like:

if(some comparison is true) {code to process;}

"if" in this case is laid out like a function:

function function_name(arguments) {code to run;}

except that the code does not rely on if the arguments are TRUE or not. It just runs when you "call" it.

So is "if" really a sort of function? Just trying to think outside of the proverbial box here.

darkflux
  • 93
  • 1
  • 1
  • 8
  • 1
    No, `if` is a language construct not a function. This post goes into a good explanation on the difference: https://stackoverflow.com/questions/1180184/what-is-the-difference-between-a-language-construct-and-a-built-in-function-in – TheGentleman Oct 13 '20 at 19:31
  • educational. thank you everyone. i learn more and more each day! – darkflux Oct 15 '20 at 01:50

1 Answers1

0

Strictly speaking: no. It is a language construct.

PHP does even have docs on specific keywords, like if.

Since you were asking for "sort of": That kind of depends on your definition of "sort of". For organizing in your mind how it works you can think like that, but it might also be a pitfall since for example the scope for variables is not only inside the if-block (like it would be in a function), amongst other concerns.

ArSeN
  • 5,133
  • 3
  • 19
  • 26