Skip to content
Advertisement

Tag: php-7

2 dimensional associative array sorting with conditional statements in PHP

I’m having trouble figuring out how to solve this question, it’s from a free online test website. Here’s the link: https://www.testdome.com/questions/php/league-table/19939?questionIds=7278,19939&generatorId=30&type=fromtest&testDifficulty=Hard But to be clearer, I’m writing the question and my answer as well. The starting answer is there in the link written above. Question: The LeagueTable class tracks the score of each player in a league. After each game,

Get class name minus namespace without using Reflection

Is there a simple way to get the class name without the namespace without using Reflection? This is my class and when I call get_class() I get CRMPiccoBundleServicesRFCWebhookSiteCancelled Answer Or simply exploding the return from class_name and getting the last element: Or simply removing the namespace from the output of get_class: Either works with or without namespace. And so on.

Variable variables in classes using PHP 7

Actually I’m migrating a bigger project from PHP 5.3.3 to PHP 7.1.13. In older versions of PHP it was possible to code following access to variable variables: This shows: Using the same code in PHP 7 it shows: In PHP 7 I figured out, that I have to use this way to get the same result: I found in the

PHP binding method to another class

Can i bind method of class Foo to class Bar? And why the code below throws a warning “Cannot bind method Foo::say() to object of class Bar”? With function instead of method code works fine. P.S. I know about extending) it is not practical question, just want to know is it real to bind non-static method to another class Code

usort difference php7.1 vs php5.6

I’m currently migrating a project from php5.6 to php7.1. Most is going well, but I just hit a wall on a test. The function usort doesn’t have the same behavior on both version, and it doesn’t seem to be documented (it’s not that two values are equals and then the order is undefined). In my test case, the returned array

Advertisement