$csrf_token = $phery->csrf(); /** * To separate the callback from the rest of the other functions, * just call a second process() */ $phery->callback(array('before' => 'pre_callback', 'after' => 'post_callback'))->set(array('test3' => function ($args, $param) { // Lambda/anonymous function, without named parameters, using ordinal indexes return PheryResponse::factory()->alert($args[0])->alert($args[1])->alert($param['param1'])->alert((string) $param[0])->alert((string) $param[1]); }, 'the_one_with_expr' => 'the_one_with_expr'))->data(array('param1' => 'named as param1'), 1, 'argument')->process(false); $phery->config(array('error_reporting' => E_ALL))->callback(array('before' => array(), 'after' => array()))->set(array('on_purpose_exception' => function () { strlen($code); }, 'deep-nesting' => function () { $r = new PheryResponse('<h3/>'); $d = new PheryResponse('<p/>'); $v = new PheryResponse('<div id="blah_' . mt_rand() . '"/>'); return $r->append($d->append($v->text('this element can be clicked')->bind('click', PheryFunction::factory('function(){ alert(this.id); }'))))->insertAfter(PheryResponse::factory()->this); }, 'colorbox' => function ($data) { if (!empty($data['close'])) { return PheryResponse::factory()->access(array('$', 'colorbox'))->close(); } if (empty($data['other-way-around'])) { return PheryResponse::factory()->jquery->colorbox(array('html' => Phery::link_to('Look, im inside PHP, loaded with everything already ;)<br>Clicking this will call $.colorbox.close();', 'colorbox', array('args' => array('close' => true))))); } return PheryResponse::factory()->jquery->colorbox(array('inline' => true, 'href' => PheryResponse::factory()->this->parent())); }, 'fileupload' => function ($data) { $r = new PheryResponse(); $files = $r->files('files'); foreach ($files as $index => $file) { unset($files[$index]['tmp_name']); } return $r->dump_vars($files);