• 24-10-2014, 13:25:05
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba,

    PHP 5.6 ile yepyeni özellikler eklendi. Benim görüşüme göre PHP daha güzel bir hale bürünüyor. Çoğu zamandır beklenen özellikler bu sürümde eklenmiş oldu. Bu özelliklerden bahsetmek gerekirse şu şekilde listeleyebiliriz.

    #1: Constant scalar expressions

    Örnek:
    <?php
    
    	const ONE = 1;
    	const TWO = ONE * 2;
    
    	class C
    	{
    
    		const THREE = TWO + 1;
    		const ONE_THIRD = ONE / self::THREE;
    		const SENTENCE = 'The value of THREE is '.self::THREE;
    
    		public function f($a = ONE + self::THREE)
    		{
    			return $a;
    		}
    
    	}
    
    	echo (new C)->f()."\n";
    
    	echo C::SENTENCE;
    Çıktı:
    4
    The value of THREE is 3
    #2: Variadic Functions via ...

    func_get_args()'a biraz benzer bir syntax yapısı eklendi.

    Örnek:
    <?php
    
    	function f($req, $opt = null, ...$params)
    	{
    		// $params is an array containing the remaining arguments.
    		printf('$req: %d; $opt: %d; number of params: %d'."\n",
    				$req, $opt, count($params));
    	}
    
    	f(1);
    	f(1, 2);
    	f(1, 2, 3);
    	f(1, 2, 3, 4);
    	f(1, 2, 3, 4, 5);
    $req: 1; $opt: 0; number of params: 0
    $req: 1; $opt: 2; number of params: 0
    $req: 1; $opt: 2; number of params: 1
    $req: 1; $opt: 2; number of params: 2
    $req: 1; $opt: 2; number of params: 3
    #3: Argument unpacking via ...

    Örnek:
    <?php
    
    	function add($a, $b, $c)
    	{
    	return $a + $b + $c;
    	}
    
    	$operators = [2, 3];
    	echo add(1, ...$operators);
    Çıktı:
    6
    #4: Exponentiation via **

    Örnek:
    <?php
    
    	printf("2 ** 3 ==      %d\n", 2 ** 3);
    	printf("2 ** 3 ** 2 == %d\n", 2 ** 3 ** 2);
    
    	$a = 2;
    	$a **= 3;
    	printf("a ==           %d\n", $a);
    Çıktı:
    2 ** 3 ==      8
    2 ** 3 ** 2 == 512
    a ==           8
    #5: use function and use const

    Örnek:
    <?php
    
    	namespace Name\Space
    	{
    		const FOO = 42;
    		function f()
    		{
    			echo __FUNCTION__."\n";
    		}
    	}
    
    	namespace
    	{
    		use const Name\Space\FOO;
    		use function Name\Space\f;
    
    		echo FOO."\n";
    		f();
    	}
    Çıktı:
    42
    Name\Space\f
    Diğer yeniliklere bu sayfadan ulaşabilirsiniz.
  • 25-10-2014, 02:05:22
    #2
    Önemli ve kullanışlı yenilikler olmuş. Ayrıca 2 gigabyte dan büyük dosyaları da halletmişler