5

in C++, all functions must be defined before using them. In PHP, can I use a function before defining it? Will it be slower?

4
  • 2
    What are you talking about? The only "using" I know is in C#. Commented Jan 9, 2011 at 6:12
  • @taspeotis: Not everybody bothers to backtick their keywords. But good call. Commented Jan 9, 2011 at 6:21
  • @taspeotis i don't know what you mean. Commented Jan 9, 2011 at 7:36
  • 3
    @lovespring: using is a keyword in C#. What taspeotis means is that the word "using" in the English language does not always refer to using in C#. Commented Jan 9, 2011 at 7:46

2 Answers 2

11

Since PHP is an interpreted language—not a compiled one—the order does not usually matter, since the contents of the script are parsed prior to the code being executed. There are a few exceptions, particularly when the existence of a function is conditional on some other code being executed.

You can read about this topic in the PHP manual here: http://www.php.net/manual/en/functions.user-defined.php

Sign up to request clarification or add additional context in comments.

Comments

3

In C++, we need to declare a function before using it. Not so in PHP: functions need not be defined before they are referenced.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.