Skip to content

php call class function by string name

How can I call a normal (not static) class function by its name? The below gives an error saying param 1 needs to be a valid callback. I don’t want the function to be static, I want it to be a normal function, and all the examples I’ve seen so far had them static. Answer The callback syntax is a

Sort by date function with variable field name

The problem I’m having is passing the variable field_name to the date_compare function, which can only take two variables due to the usort method. date_compare function must also be wrapped in a variable to avoid redeclaring a function if it is called more than once. m I even going about this the right …

Delete specific characters in text-file php

I have a text like that : I want to delete the , in front of frank or eclipse, it can be any word. My idea is to check if with have a comma before Eclipse:, or accueil: and if with have one then we delete only the comma to have : But how can we delete just one commat

manipulate a result set from laravel eloquent

I’ve just picked up laravel after deciding to move to a php framework. I’m retrieving a result set of articles from a database using an eloquent query: this works fine and results come out as expected. However I now want to change the format of the article date from the mysql date format to anothe…

PHP Multiple Username & Passwords

So, this is probably the simplest question I could ever possibly ask.. Though it is driving me insane. In my login system, I have it set up to read the username and password from a standalone file “users.php” inside it contains I can not, for the life of me figure out how to make it read multiple …

Laravel 4 always returns HTTP status code 200

I have below code in error.php, which is triggered using App::abort(404, $error) in my controller. Still my response status code is 200(ok). I tried with various error codes like 400, 403 Answer For anyone still googling this problem: I was struggling with this problem for hours. For me the problem was caused…