SlideShare a Scribd company logo
PHP
Array: New syntax & dereferencing
                  support
$a = array(1,2,3);
 $


$b = array('foo' => 'orange', 'bar' => 'apple');
$
Array: New syntax & dereferencing
                  support
$a = array(1,2,3);
$a = [1,2,3];


$b = array('foo' => 'orange', 'bar' => 'apple');
$b = ['foo':'orange','bar':'apple','baz':'lemon'];
$b = ['foo' => 'orange‘ , 'bar' => 'apple' , 'baz' => 'lemon' ];
Array: New syntax & dereferencing
                  support
function fruit()
{
       return array('a'=>'apple', 'b'=>'banana');
}

$var = fruit();
echo $var['a']; //apple
Array: New syntax & dereferencing
                  support
function fruit()
{
       return array('a'=>'apple', 'b'=>'banana');
}

$var = fruit();
echo $var['a'];

echo fruit()['a']; //apple
Непрямий виклик методу змінної
           масиву
Непрямий виклик методу змінної
           масиву

       class Test {
              public function world($x){
                     echo "Hello, $x";
                     return $this;
              }
       }

       $f = array('Test','world');
       $f('you');    // Hello, you
Непрямий виклик методу змінної
           масиву
Traits OR Horizontal Reuse OR Multiple
               Inheritance
trait Hello {
      public function hello() {
      return "Hello";
   }
}

trait City {
      public function city($name) {
      return $name;
   }
}

class Welcome {
   use Hello, City;
}

$var = new Welcome();
echo $var->hello(). ' '. $var->city("Montreal"); // Hello Montreal
Traits OR Horizontal Reuse OR Multiple
               Inheritance
trait Hello {
      public function hello() {
      return "Hello";
   }
}

trait City {
      public function city($name) {
      return $name;
   }
}

class Welcome {
   use Hello, City;
}

$var = new Welcome();
echo $var->hello(). ' '. $var->city("Montreal");

echo (new Welcome())->hello(), ' ', (new Welcome())->city("Montreal");   // Hello Montreal
Traits OR Horizontal Reuse OR Multiple
                  Inheritance
trait Hello {
      public function hello() {
      return "Hello"; }
}

trait City {
      public function city($name) {
      return $name; }
}

trait Greeting {
    use Hello, City;
    public function greeting($name) {
      echo $this->hello(), ' ', $this->city($name); }
}
class Welcome { use Greeting; }

echo (new Welcome())->greeting("Montreal");             // Hello Montreal
Traits. Encapsulation

trait Hello {
   private function hello($city) {
      echo "Hello " , $city;
   }
}

class Welcome {
   use Hello {
     hello as public;
   }
}

(new Welcome())->hello("Montreal");   // "Hello Montreal"
Traits. Encapsulation

trait Hello {
   private function hello($city) {
      echo "Hello " , $city;
   }
}

class Welcome {
   use Hello {
     hello as public;
   }
}

(new Welcome())->hello("Montreal");   // Fatal error: Call to private method Welcome::hello()…
Traits

trait Who {
   public function msg($name) { return $name; }
}

trait Hello {
    private function msg() { return "Hello"; }
}

class Welcome {
    use Who, Hello {
      hello::msg as public hi;
      Who::msg insteadof Hello;
    }
}

$w = new Welcome();

echo $w->hi(), ' ', $w->msg("Montreal");         // "Hello Montreal"
Traits. Identifying traits
trait Hello {
   public function hi() { return 'Hello'; }
}

class Welcome {
    use Hello { hello::hi as public hello; }
}

$rc = new ReflectionClass('Welcome');

if (!$rc->isTrait()) {
    echo $rc->getTraitNames()[0];               // prints "Hello"
    echo $rc->getTraitAliases()['hello'];       // prints "hello::hi"
    foreach ($rc->getTraits() as $v) {
        echo $v->getMethods()[0]->class, ' ',
        $v->getMethods()[0]->name;              // prints "hello hi"
    }
}
Upload progress


                        був в HTML 5 File API
                        і в nginx-upload-progress-module




Тепер в сесії користувача в ключі upload_progress_formname
Upload progress
WebServer inside
2012
Register Globals & Register long arrays (HTTP_GET_VARS)
Safe Mode
Magic Quotes
break $foo; та continue $bar;
SQLite 2 extension (тепер SQLite 3)
В $_SERVER['REQUEST_TIME'] тепер передається в мікросекундах
default_charset = UTF-8
http_response_code()
header_register_callback

mixed call_user_func ( callable $callback [, mixed $parameter [, mixed $... ]] )
Fin

А що більше всього сподобалося Вам?

• Traits

• Новий синтаксис масивів

• Розіменування

• Непрямий виклик

• WebServer inside

More Related Content

PDF
"Is there life in react without redux" by Babich Sergiy. OdessaJS'2021
PPTX
Social media & you (Changeyou)
PPT
Communication
PPT
Communication
PPTX
Social media seo and ppc
PPTX
Social Media Tips
PPTX
Hadoop: The elephant in the room
PPTX
Social media change you how you can get help in revenue
"Is there life in react without redux" by Babich Sergiy. OdessaJS'2021
Social media & you (Changeyou)
Communication
Communication
Social media seo and ppc
Social Media Tips
Hadoop: The elephant in the room
Social media change you how you can get help in revenue
Ad

PHP

  • 2. Array: New syntax & dereferencing support $a = array(1,2,3); $ $b = array('foo' => 'orange', 'bar' => 'apple'); $
  • 3. Array: New syntax & dereferencing support $a = array(1,2,3); $a = [1,2,3]; $b = array('foo' => 'orange', 'bar' => 'apple'); $b = ['foo':'orange','bar':'apple','baz':'lemon']; $b = ['foo' => 'orange‘ , 'bar' => 'apple' , 'baz' => 'lemon' ];
  • 4. Array: New syntax & dereferencing support function fruit() { return array('a'=>'apple', 'b'=>'banana'); } $var = fruit(); echo $var['a']; //apple
  • 5. Array: New syntax & dereferencing support function fruit() { return array('a'=>'apple', 'b'=>'banana'); } $var = fruit(); echo $var['a']; echo fruit()['a']; //apple
  • 6. Непрямий виклик методу змінної масиву
  • 7. Непрямий виклик методу змінної масиву class Test { public function world($x){ echo "Hello, $x"; return $this; } } $f = array('Test','world'); $f('you'); // Hello, you
  • 8. Непрямий виклик методу змінної масиву
  • 9. Traits OR Horizontal Reuse OR Multiple Inheritance trait Hello { public function hello() { return "Hello"; } } trait City { public function city($name) { return $name; } } class Welcome { use Hello, City; } $var = new Welcome(); echo $var->hello(). ' '. $var->city("Montreal"); // Hello Montreal
  • 10. Traits OR Horizontal Reuse OR Multiple Inheritance trait Hello { public function hello() { return "Hello"; } } trait City { public function city($name) { return $name; } } class Welcome { use Hello, City; } $var = new Welcome(); echo $var->hello(). ' '. $var->city("Montreal"); echo (new Welcome())->hello(), ' ', (new Welcome())->city("Montreal"); // Hello Montreal
  • 11. Traits OR Horizontal Reuse OR Multiple Inheritance trait Hello { public function hello() { return "Hello"; } } trait City { public function city($name) { return $name; } } trait Greeting { use Hello, City; public function greeting($name) { echo $this->hello(), ' ', $this->city($name); } } class Welcome { use Greeting; } echo (new Welcome())->greeting("Montreal"); // Hello Montreal
  • 12. Traits. Encapsulation trait Hello { private function hello($city) { echo "Hello " , $city; } } class Welcome { use Hello { hello as public; } } (new Welcome())->hello("Montreal"); // "Hello Montreal"
  • 13. Traits. Encapsulation trait Hello { private function hello($city) { echo "Hello " , $city; } } class Welcome { use Hello { hello as public; } } (new Welcome())->hello("Montreal"); // Fatal error: Call to private method Welcome::hello()…
  • 14. Traits trait Who { public function msg($name) { return $name; } } trait Hello { private function msg() { return "Hello"; } } class Welcome { use Who, Hello { hello::msg as public hi; Who::msg insteadof Hello; } } $w = new Welcome(); echo $w->hi(), ' ', $w->msg("Montreal"); // "Hello Montreal"
  • 15. Traits. Identifying traits trait Hello { public function hi() { return 'Hello'; } } class Welcome { use Hello { hello::hi as public hello; } } $rc = new ReflectionClass('Welcome'); if (!$rc->isTrait()) { echo $rc->getTraitNames()[0]; // prints "Hello" echo $rc->getTraitAliases()['hello']; // prints "hello::hi" foreach ($rc->getTraits() as $v) { echo $v->getMethods()[0]->class, ' ', $v->getMethods()[0]->name; // prints "hello hi" } }
  • 16. Upload progress  був в HTML 5 File API  і в nginx-upload-progress-module Тепер в сесії користувача в ключі upload_progress_formname
  • 19. 2012 Register Globals & Register long arrays (HTTP_GET_VARS) Safe Mode Magic Quotes break $foo; та continue $bar; SQLite 2 extension (тепер SQLite 3) В $_SERVER['REQUEST_TIME'] тепер передається в мікросекундах default_charset = UTF-8 http_response_code() header_register_callback mixed call_user_func ( callable $callback [, mixed $parameter [, mixed $... ]] )
  • 20. Fin А що більше всього сподобалося Вам? • Traits • Новий синтаксис масивів • Розіменування • Непрямий виклик • WebServer inside