0

Hi I keep getting an Unexpected T_function error on the last line when i run the below code on a webserver running php 5.2, this runs fine on my local machine running php 5.3.6

 // ***** Declare function that buids the post type
 function add_post_type($name, $args = array() ) {
    add_action('init',function() use($name, $args) {

can somebody help me spot whats wrong?

1
  • Fixed it, apparently this is a mirror of another question. apologies. Commented Sep 16, 2012 at 22:10

3 Answers 3

1

Anonymous functions aren't available until PHP 5.3. See the changelog.

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

Comments

0

The piece of code:

function() use($name, $args) { ..

it's an anonymous function (or closure). Anonymous functions are avaiable since PHP 5.3.0

Comments

0

PHP 5.2 doesn't support anonymous functions

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.