
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;
$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;
Cloudflare Registrar securely registers and manages your domain names with transparent, no-markup pricing(net stock price) that eliminates surprise renewal fees and hidden add-on charges. You pay what we pay — you won’t find better value.
This list is in US Dollars.
(more…)The rel
attribute specifies the relationship between the current document and the linked document. Search engines can use this attribute to get more information about a link.
rel
Attribute Valuesnofollow | Links to an unendorsed document, like a paid link. (“nofollow” is used by Google, to specify that the Google search spider should not follow that link) |
noreferrer | Requires that the browser should not send an HTTP referer header if the user follows the hyperlink |
noopener | Requires that any browsing context created by following the hyperlink must not have an opener browsing context |
Add the following code into your HTML page between the <head>
and </head>
tags or before the closing </body>
tag
<script> document.addEventListener('DOMContentLoaded', function () { var links = document.getElementsByTagName("a"); var i; for (i = 0; i < links.length; i++) { if (location.hostname !== links[i].hostname) { links[i].rel = "nofollow noopener noreferrer"; links[i].target = "_blank"; } } }); </script>
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 else it will return the equivalent IPv6
function convert_ipv4_to_ipv6($ip) { if (!filter_var($ip, FILTER_VALIDATE_IP)) { return false; } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { return $ip; } $bytes = array_map('dechex', explode('.', $ip)); return vsprintf('0:0:0:0:0:ffff:%02s%02s:%02s%02s', $bytes); }
Below is a snippet of the code and usage guide.
function colourBrightness($hex, $percent) { // Work out if hash given $hash = ''; if (stristr($hex, '#')) { $hex = str_replace('#', '', $hex); $hash = '#'; } /// HEX TO RGB $rgb = [hexdec(substr($hex, 0, 2)), hexdec(substr($hex, 2, 2)), hexdec(substr($hex, 4, 2))]; //// CALCULATE for ($i = 0; $i < 3; $i++) { // See if brighter or darker if ($percent > 0) { // Lighter $rgb[$i] = round($rgb[$i] * $percent) + round(255 * (1 - $percent)); } else { // Darker $positivePercent = $percent - ($percent * 2); $rgb[$i] = round($rgb[$i] * (1 - $positivePercent)); // round($rgb[$i] * (1-$positivePercent)); } // In case rounding up causes us to go to 256 if ($rgb[$i] > 255) { $rgb[$i] = 255; } } //// RBG to Hex $hex = ''; for ($i = 0; $i < 3; $i++) { // Convert the decimal digit to hex $hexDigit = dechex($rgb[$i]); // Add a leading zero if necessary if (strlen($hexDigit) == 1) { $hexDigit = "0" . $hexDigit; } // Append to the hex string $hex .= $hexDigit; } return $hash . $hex; }
You do not have to give the color with the ‘#’ in front but if you do it will still return the new hex color with the ‘#’ auto-magically.
$colour = '#ae64fe'; $brightness = 0.5; // 50% brighter $newColour = colourBrightness($colour, $brightness);
$colour = '#ae64fe'; $brightness = -0.5; // 50% darker $newColour = colourBrightness($colour, $brightness);
Let say you have a table called “my_table” with an auto-increment column called “id” and you want the id column to start counting from 1,2,3,… then use the following SQL queries.
SET @num := 0; UPDATE my_table SET id = @num := (@num+1); ALTER TABLE my_table AUTO_INCREMENT =1;
// Gets the current store’s details $store = Mage::app()->getStore(); // Gets the current store’s id $storeId = Mage::app()->getStore()->getStoreId(); // Gets the current store’s code $storeCode = Mage::app()->getStore()->getCode(); // Gets the current website’s id $websiteId = Mage::app()->getStore()->getWebsiteId(); // Gets the current store’s group id $storeGroupId = Mage::app()->getStore()->getGroupId(); // Gets the current store’s name $storeName = Mage::app()->getStore()->getName(); // Gets the current store’s sort order $storeSortOrder = Mage::app()->getStore()->getSortOrder(); // Gets the current store’s status $storeIsActive = Mage::app()->getStore()->getIsActive(); // Gets the current store’s locale $storeLocaleCode = Mage::app()->getStore()->getLocaleCode(); // Gets the current store’s home url $storeHomeUrl = Mage::app()->getStore()->getHomeUrl();
What are the differences between git pull and git fetch?
Answer:
In the simplest terms, git pull
does a git fetch
followed by a git merge
.
You can do a git fetch
at any time to update your remote-tracking branches under refs/remotes/<remote>/
. This operation never changes any of your own local branches under refs/heads
, and is safe to do without changing your working copy. I have even heard of people running git fetch
periodically in a cron job in the background (although I wouldn’t recommend doing this).
A git pull
is what you would do to bring a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
Git documentation: git pull
Recent Comments