4

I know you can do something like this in PHP5:

function sayHi() {
    echo "Hi!";
}

$func = "sayHi";
$func();

It is called a variable function in the documentation. But the docs don't say anything about what versions of PHP this works on. This could mean it works on ALL versions of PHP, but I doubt it. Specifically, does this work on PHP4?

chowey
  • 9,138
  • 6
  • 54
  • 84

2 Answers2

1

For php 4.3 they are working. Build-in function test here, your source test here.

BlitZ
  • 12,038
  • 3
  • 49
  • 68
  • Thanks, do you know if this was implemented as of 4.3.0? – chowey Oct 03 '13 at 03:26
  • @chowey I can not find it. Also, I have no php 3 or later distributive to test that. As you noticed, Zend ommited this information in their docs. – BlitZ Oct 03 '13 at 03:29
  • @chowey PHP4 was horribly written under the hood and was build on Zend Engine 1. It had also a lot of bugs. It's 2013 now, even `PHP5.2` is considered as extremely outdated. – Yang Oct 03 '13 at 06:25
  • True, but one cannot always control his deployment environment. – chowey Oct 03 '13 at 19:49
1

Definitely Yes. As you can see in here when there is a dependency in a certain function they set it below the title.

No dependcy in version of php

VARIABLE Functions

With dependency in version of php

INTVAL Function

note: so whenever you have concerns on a certain function that you will use regards on your php version better consult php.net for info.

Jhonathan H.
  • 2,734
  • 1
  • 19
  • 28
  • So this thing has been around since before PHP4? – chowey Oct 03 '13 at 03:29
  • @chowey yup as stated in their site i think you widely could use it on diferrent versions of php since start. You could always see it there whether its depricated or which versions can it only be run there. If theres nothing states about under it . Its means u can use it widely. – Jhonathan H. Oct 03 '13 at 03:31
  • 1
    Fair enough. There are comments on that page dating back 10 years, so its been supported for at least that long. – chowey Oct 03 '13 at 03:37
  • 1
    Also it looks like they don't always tell you the version dependency under the header. Example is the page on [anonymous functions](http://php.net/manual/en/functions.anonymous.php) which has only been around since PHP 5.3.0. – chowey Oct 03 '13 at 03:39
  • i think because it just comes from a new versions of PHP and not later thant 5.0 below . – Jhonathan H. Oct 03 '13 at 03:51
  • 1
    @chowey, in that page of the anonymous functions, in the changelog section, they say: `5.3.0 Anonymous functions become available`. It isn't below the header, but, at least, it's in somewhere. – Rafael Barros Apr 22 '14 at 11:53