PHP: Get the PHP extension name of a class by the class name
$class_name = 'DOMDocument'; $class = new ReflectionClass($class_name); $extension = $class->getExtension(); echo $extension;
PHP, which stands for “Hypertext Preprocessor”, is a server-side, HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web developers to write dynamically generated pages quickly.
$class_name = 'DOMDocument'; $class = new ReflectionClass($class_name); $extension = $class->getExtension(); echo $extension;
$extension_name = 'dom'; $extension = new ReflectionExtension($extension_name); print_r($extension->getFunctions()); print_r($extension->getClassNames());
$function_name = 'imagecreate'; $class = new ReflectionFunction($function_name); $extension = $class->getExtension(); echo $extension;
The following PHP function will help you easily convert IPv4(IP address version 4) to IPv6(IP address version 6). The function will return false if the provided IP address is invalid…
Below is a snippet of the code and usage guide. PHP Function function colourBrightness($hex, $percent) { // Work out if hash given $hash = ''; if (stristr($hex, '#')) { $hex…
The script below loops over the specified directory and chmods its files, directories and subdirectories recursively.
IDs are often numbers. Unfortunately there are only 10 digits to work with, so if you have a lot of records, IDs tend to get very lengthy. For computers that’s OK. But human beings like their IDs as short as possible. So how can we make IDs shorter? Well, we could borrow characters from the alphabet as have them pose as additional numbers…. Alphabet to the rescue!
I created this function a long time ago. Time to be nice and share.
The alphabet has 26 characters. That’s a lot more than 10 digits. If we also distinguish upper- and lowercase, and add digits to the bunch or the heck of it, we already have (26 x 2 + 10) 62 options we can use per position in the ID.
Now of course we can also add additional funny characters to ‘the bunch’ like – / * & # but those may cause problems in URLs and that’s our target audience for now.
OK so because there are roughly 6x more characters we will use per position, IDs will get muchshorter. We can just fit a lot more data in each position.
This is basically what url shortening services do like tinyurl, is.gd, or bit.ly. But similar IDs can also be found at youtube: http://www.youtube.com/watch?v=yzNjIBEdyww
(more…)
In this tutorial, i will show you how to implement jQuery UI’s autocomplete widget in cakephp. The script in this tutorial is copy paste from tutorialzine article “A Simple Movie Search App w/ jQuery UI” . We are using a MySql database containing a users table. When you start typing a user name in the text box of the search form, an AJAX request is sent to controller. The controller returns a JSON object with suitable user name.
This is what we’re going to create:
(more…)
This article shows how to add query parameters to a URL in a php script. It is aimed at the beginner to intermediate level PHP programmer but developers from other languages may find some useful information here. At first this seems like a simple enough task. Starting with the url as a string, just add the new parameters to the end. Yeah, that would be nice. It turns out that there are a few conditions that make the process just a bit more difficult. It’s still not a hard problem but there are enough special cases to make it interesting.
(more…)
There is some tweaking that we need to perform in order to make sure that Apache runs CakePHP applications smoothly. Many Apache installations may not require the following tweaking, as they might be set as default, but it is always a good idea to check if the following settings are present.
(more…)