Re: Re: PHP Fatal error: Call to undefined function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5-3-2015 15:57, Aziz Saleh wrote:
On Thu, Mar 5, 2015 at 9:49 AM, Pete Ford <pete@xxxxxxxxxxxxx> wrote:

On 05/03/15 14:42, Maciek Sokolewicz wrote:

On 5-3-2015 13:04, hadi wrote:

Hi,

I created function, but im getting error:

(PHP Fatal error:  Call to undefined function rss1() in
C:\phptest\test9.php
on line 17)


The error explains it perfectly. You're calling a function which has not
been defined yet. So... define your function BEFORE you call it, not
AFTER calling it.

So
<?php
function rss1() { ... }
rss1();

instead of
<?php
rss1();
function rss1() { ... }

- Tul

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



There is also the problem is that his function is being defined inside the
Exception block (as far as I can tell from the parentheses) which looks
weird...


--
Peter Ford                            phone: 01580 893333 fax: 01580 893399
Justcroft International Ltd.
www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


In PHP you can call any function regardless if its before or after, as long
as it is within the scope. In your case like Pete mentioned, your function
is in your Exception scope. You have 2 options:

1) Please the function outside of the try/catch statement.
2) If you need to keep it within, move it on top of your function call.


I know that, and you know that, but I also know Hadi wouldn't understand this (as is pointed out in the hundreds of other extremely basic questions posted earlier); so attempting to answer his question in the easiest manner possible (undefined? define before using!) was what I was trying to do. Trying to explain scope and runtime evaluation of function definitions isn't something that he would understand (yet) anyway.
- Tul

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux