Login   Register  
PHP Classes
elePHPant
Icontem

File: Example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Abraham Cruz Sustaita  >  PHP Anonymous Function use keyword  >  Example.php  >  Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example
Class: PHP Anonymous Function use keyword
Call functions dynamically added to objects
Author: By
Last change:
Date: 1 year ago
Size: 225 bytes
 

Contents

Class file image Download
<?php
include_once "Core/Std.php";
$new = new Core_Std;
$new->3;
$new->sum = function($a$b) use ($new) {
    return 
$a $b $new->c;
};

$total $new->sum(1,2);
echo 
$total// This will print 6 ( 1 + 2 + 3)