How to use dynamic text in an html/htm page
Whether you have a Joomla, WordPress, or E-commerce website, updating the copyright year on your website may not be a legal requirement, but it’s a smart marketing method to prove that your business is active. Showing the year is especially important if you have a site without dates on its content. There’re many ways you can automatically refresh the copyright year by inserting a simple JavaScript or php script (see below) into your website’s html code, or you can manually change the year in the…
Using glob() function in PHP
To find pathnames matching a pattern such as .html or .php, you’ll use this glob() function. The return value is an array of files that has the matched pattern that you defined. Function: array glob ( string $pattern [, int $flags = 0 ] ) Usage: foreach (glob(“*.htm”) as $filename) { echo “$filename size ” . filesize($filename) . “\n”; } You can use this function to manage file system on your server. Example: Using array_map function to perform a callback to the elements of a…
How to insert an image to MySql database with php
A BLOB is a binary large object that can hold a variable amount of data. There’re 4 datatypes that you can select for a blob field, depending how much storage of an image you’ll need. TINYBLOB A binary large object column with a maximum length of 255 (2^8 – 1) characters. BLOB A binary large object column with a maximum length of 65535 (2^16 – 1) characters. MEDIUMBLOB A binary large object column with a maximum length of 16777215 (2^24 – 1) characters. LONGBLOB A…
Using base64 to encode your data
Recently, I have got a project that requires a Web Service to transport data back and forth between an Android application and Linux server. As you know, Android also supports JSON to transfer data and communicate with a web service that way. So, we decided to use base64 as a middle man to save and retrieve data. The design point is that a user can upload data and pictures from an Android to the database in cloud. Then later on, data can be retrieved using…
Should or shouldnot use eval() function to evaluates an encrypted PHP source code?
The function is eval ( string $str ) This string $str can be already decrypted from an encrypted string using Hash or bin2hex or base64. The string passed to eval() function must be valid PHP code and must end with semicolon. You can evaluate a class, a function and a string of multiple lines of php code. This function returns NULL unless a return statement is called in the code string. Then the value passed to return is returned. eval() returns FALSE if there is…