Say i have this PHP code: $FooBar = “a string”; i then need a function like this: print_var_name($FooBar); which prints: FooBar Any Ideas how to achieve this? Is this even possible in PHP?
Tag: php
Enumerations on PHP
I know that PHP doesn’t yet have native Enumerations. But I have become accustomed to them from the Java world. I would love to use enums as a way to give predefined values which IDEs’ auto-completion …
Best practices to test protected methods with PHPUnit
I found the discussion on Do you test private method informative. I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. Because most of the public methods make use of them, I will probably be able to safely remove the tests later. But for starting with
PHP syntax highlighting [closed]
I’m searching for a PHP syntax highlighting engine that can be customized (i.e. I can provide my own tokenizers for new languages) and that can handle several languages simultaneously (i.e. on the …
PHP Access Control System
I am part of a team creating a web application using PHP and MySQL. The application will have multiple users with different roles. The application will also be used in a geographically distributed …
How can I change a file’s extension using PHP?
How can I change a file’s extension using PHP? Ex: photo.jpg to photo.exe Answer In modern operating systems, filenames very well might contain periods long before the file extension, for instance: PHP provides a way to find the filename without the extension that takes this into account, then just add the new extension:
Calling Python in PHP
I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac. I don’t want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system()
.htaccess files, PHP, includes directories, and windows XAMPP configuration nightmare
XAMPP makes configuring a local LAMP stack for windows a breeze. So it’s quite disappointing that enabling .htaccess files is such a nightmare. My problem: I’ve got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, .htaccess files must be allowed in Apache and the .htaccess file must specify exactly
How to find the foreach index?
Is it possible to find the foreach index? in a for loop as follows: $i will give you the index. Do I have to use the for loop or is there some way to get the index in the foreach loop? Answer $key is the index of each $array element
Convert from MySQL datetime to another format with PHP
I have a datetime column in MySQL. How can I convert it to the display as mm/dd/yy H:M (AM/PM) using PHP?