This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This code demonstrates how to create and parse the JSON data format of using array of PHP. | |
// It's a very simple code, that allows you to perform this task. | |
// source: http://www.apphp.com/index.php?snippet=php-create-and-parse-json-data | |
$json_data = array( | |
'id'=>1,'name'=>'jackson','country'=>'usa','office'=>array('google','oracle') | |
); | |
echo json_encode | |
($json_data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ip_address = '127.0.0.1'; | |
if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $ip_address)){ | |
echo 'IP address is valid!'; | |
}else{ | |
echo 'IP address is NOT valid!'; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Class member encapsulation in JavaScript is very important thing and may be implemented with easy. | |
// To define private property or method just use var before the definition or this., | |
// if you need to give a public access to property or method. | |
// source: http://www.apphp.com/index.php?snippet=javascript-define-class-private-memebrs | |
<script language="javascript"> | |
FormValidator = function(){ | |
// private data member (property) | |
var _digits = "0123456789"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sometimes you need the page dimanically changes a texbox with a dropdown box. | |
// On the example below we show you how to perform this work. | |
// source: http://www.apphp.com/index.php?snippet=javascript-converting-text-input-to-select | |
<div id="buy-buttons"> | |
<label>Quantity:</label> | |
<input name="txtQuantity" id="txtQuantity" type="text" value="1" /> | |
<input type="submit" name="btnAddToCart" value="Add To Cart" id="btnAddToCart" /> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This example shows you how to create custom tooltips, using just a pure CSS. In this examples we use "transform" feature of the CSS3 and some other tricks. Also you may find additional tooltip class provided, to show you the way you may customize this code. | |
Source: http://www.apphp.com/index.php?snippet=css-pure-ccs3-animated-tooltip | |
*/ | |
<style type="text/css"> | |
.tooltip-container { | |
/* Forces tooltip to be relative to the element, not the page */ | |
position:relative; | |
cursor:help; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This solution will help you to prevent many issues with your site, when you need to prevent long URL's from breaking out of container. | |
Source: http://www.apphp.com/index.php?snippet=css-breaking-out-long-urls | |
*/ | |
<style type="text/css"> | |
.break { | |
-ms-word-break: break-all; | |
word-break: break-all; | |
word-break: break-word; | |
-webkit-hyphens: auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To get buttom with line breaks you can use carriage return characters to break the line: 
 or just <br> with a <button> tag: | |
Source: http://www.apphp.com/index.php?snippet=html-button-with-line-breaks | |
<!-- First way --> | |
<input type="button" value="This is
a Really
Tall
 Button"> | |
<!-- Second way --> | |
<button>This is<br/>a Really<br/>Tall<br/>Button</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The <!-- --> syntax is the HTML comment. This is the way to add your own notes into the code which will not display when the HTML is rendered by the browser. It is also a good practice for web-developers to use the comment tags to "hide" scripts from browsers without support for it (so they don't show them as a plain text). | |
Source: http://www.apphp.com/index.php?snippet=html-comments-tag | |
<!-- This is a comment. Comments are not displayed in the browser. --> | |
<div id="header"> | |
<p>Some text</p> | |
</div> <!-- END div-header --> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* MySQL has a handy and simple string function REPLACE() that allows table data with the matching string to be replaced by new string. This is useful if there is need to search and replace a text string which affects many records or rows, such as change of address, company name, URL or spelling mistake. | |
Source: http://www.apphp.com/index.php?snippet=mysql-find-and-replace | |
*/ | |
-- 1st example | |
UPDATE files SET filepath = REPLACE(filepath,'path/to/search','path/to/replace'); | |
-- 2nd example | |
UPDATE customers SET address = REPLACE(address,'_CODE_',postcode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is a very simple snippet about how to create a database 1st, | |
a user and then assign some privileges to the user to allow him/her to | |
perform some specific actions like insert, create, update, select etc. | |
Source: http://www.apphp.com/index.php?snippet=mysql-create-database-and-assign-user | |
*/ | |
-- Create database, user and grant all privileges | |
CREATE DATABASE database_name; | |
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'password'; |
OlderNewer