PHP Classes

File: Example.php

Recommend this page to a friend!
  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: 10 years ago
Size: 225 bytes


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

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