PHP “&” operator

Those are references, and they are similar to “pointers” in C or C++. More information is in the PHP manual. In this case, since $db_hosts is empty, the construct $db_hosts[$db_item[‘hostid’]] will create a new array with an empty item on the index of $db_item[‘hostid’] and return the item’s reference, making $db_host act as an ‘alias’ for whatever $db_hosts[$db_item[‘hostid’]] is currently.

Fatal error: Out of memory, but I do have plenty of memory (PHP)

I ran accross the same kind of problem with the server dying when trying to use the swap. This is because mod_php does not free memory ever. So Apache processes keep growing either reaching apache or PHP’s memory limit or, if there’s no limit, crashing the server. Restarting apache makes it to spawn new fresh slim … Read more

How to convert string to boolean php

Strings always evaluate to boolean true unless they have a value that’s considered “empty” by PHP (taken from the documentation for empty): “” (an empty string); “0” (0 as a string) If you need to set a boolean based on the text value of a string, then you’ll need to check for the presence or otherwise of that value. … Read more

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

Changing the memory_limit by ini_set(‘memory_limit’, ‘-1′); is not a proper solution. Please don’t do that. Your PHP code may have a memory leak somewhere and you are telling the server to just use all the memory that it wants. You wouldn’t have fixed the problem at all. If you monitor your server, you will see that it is now probably using … Read more

Document Root PHP

Try this yourself and find that they are not exactly the same. $_SERVER[‘DOCUMENT_ROOT’] renders an actual file path (on my computer running as it’s own server, C:/wamp/www/ HTML’s / renders the root of the server url, in my case, localhost/ But C:/wamp/www/hello.html and localhost/hello.html are in fact the same file

What does MYSQLI_NUM mean and do?

MYSQLI_NUM is a constant in PHP associated with a mysqli_result. If you’re using mysqli to retrieve information from the database, MYSQLI_NUM can be used to specify the return format of the data. Specifically, when using the fetch_array function, MYSQLI_NUM specifies that the return array should use numeric keys for the array, instead of creating an … Read more

Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 201:

This is how I do it. Routes.php admin_login.blade.php dashboard.blade.php UsersController.php Your Code: In routes.php, you have only 1 route, i.e., And there is no declaration of post method, hence, the MethodNotAllowedHttpException Also, in your controller, you are returning the view first and then processing the form which is not going to work at all. You first need to process … Read more

MySQL query to get column names?

The best way is to use the INFORMATION_SCHEMA metadata virtual database. Specifically the INFORMATION_SCHEMA.COLUMNS table… It’s VERY powerful, and can give you TONS of information without need to parse text (Such as column type, whether the column is nullable, max column size, character set, etc)… Oh, and it’s standard SQL (Whereas SHOW … is a MySQL specific extension)… For more information … Read more

PHP to write Tab Characters inside a file?

The tab character is \t. Notice the use of ” instead of ‘. PHP Strings – Double quoted If the string is enclosed in double-quotes (“), PHP will interpret more escape sequences for special characters: … \t horizontal tab (HT or 0x09 (9) in ASCII) Also, let me recommend the fputcsv() function which is for the purpose of writing CSV files.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)