# How expensive are function_exists() calls?

- Thread: https://externals.io/message/43239
- Original archive: https://news-web.php.net/php.internals/43239
- Started by mike on 2009-03-04T11:01:55+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43239 — mike — 2009-03-04T11:01:55+00:00

URL: https://externals.io/message/43239#43239

I am trying to figure out a strategy for multiple output formats on a
site, and it seems like I can have functions defined by default, but
have them defined -after- I've included the targetted format first.

However that would require

file1.php:

function foo() {}

file2.php

if(!function_exists('foo')) {
   function foo() {}
}

Is this a very expensive thing to do? There would be a good number of
functions that would be leveraging this. Is it a no-no? or is it
pretty cheap?

Thanks
- mike

---

## #43245 — Kenan Sulayman — 2009-03-04T13:07:07+00:00

URL: https://externals.io/message/43239#43245 · In reply to: #43239

Hello Mike!

Depending on how you'd define expensive, it may variate.
Normally, on websites function_exists(x) ain't expensive.

Altrought function_exists needed 0.000077009201049805 seconds to execute.
Do you think, that's pretty expensive ?

Your,
--
(c) Kenan Sulayman
Freelance Designer and Programmer

Life's Live Poetry


2009/3/4 mike <mike503@gmail.com>

> I am trying to figure out a strategy for multiple output formats on a
> site, and it seems like I can have functions defined by default, but
> have them defined -after- I've included the targetted format first.
>
> However that would require
>
> file1.php:
>
> function foo() {}
>
> file2.php
>
> if(!function_exists('foo')) {
>   function foo() {}
> }
>
> Is this a very expensive thing to do? There would be a good number of
> functions that would be leveraging this. Is it a no-no? or is it
> pretty cheap?
>
> Thanks
> - mike

---

## #43246 — Mikko Koppanen — 2009-03-04T13:14:43+00:00

URL: https://externals.io/message/43239#43246 · In reply to: #43245

On Wed, Mar 4, 2009 at 1:07 PM, Kenan Sulayman <kureal@kkooporation.de>wrote:

> Hello Mike!
>
> Depending on how you'd define expensive, it may variate.
> Normally, on websites function_exists(x) ain't expensive.
>
> Altrought function_exists needed 0.000077009201049805 seconds to execute.
> Do you think, that's pretty expensive ?
>
>
Please move this thread to the php-general mailing-list.


-- 
Mikko Koppanen

---

## #43247 — Kenan Sulayman — 2009-03-04T13:20:52+00:00

URL: https://externals.io/message/43239#43247 · In reply to: #43245

Update:

Reached: Average: 1.3338460335041E-5 seconds / 817542.
Shape:
Average: ( $seconds ) seconds / ( $iterations ).

--
(c) Kenan Sulayman
Freelance Designer and Programmer

Life's Live Poetry


2009/3/4 Kenan Sulayman <kureal@kkooporation.de>

> Hello Mike!
>
> Depending on how you'd define expensive, it may variate.
> Normally, on websites function_exists(x) ain't expensive.
>
> Altrought function_exists needed 0.000077009201049805 seconds to execute.
> Do you think, that's pretty expensive ?
>
> Your,
> --
> (c) Kenan Sulayman
> Freelance Designer and Programmer
>
> Life's Live Poetry
>
>
> 2009/3/4 mike <mike503@gmail.com>
>
> I am trying to figure out a strategy for multiple output formats on a
> > […]
