Recent Notes

Displaying keyword search results 111 - 120
Created by jinx on May 03, 2011 12:11:35    Last update: May 03, 2011 12:12:27
The PHP function is_resource returns TRUE if a variable is a resource. This may come in handy when a function you are calling returns mixed type. For example mysql_query returns TRUE or FALSE for INSERT , UPDATE , DELETE etc., but returns resource or FALSE for SELECT , SHOW , or DESCRIBE . <?php $rows = array(); if ($res = mysql_quer...
Created by jinx on May 03, 2011 11:43:26    Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected. Conversion rules: Type String Value Boolean TRUE '1' Boolean FALSE '' (empty string) integer of float string representing the number Array The string 'Array' Object Result of __toString() if defined, error otherwise Resource 'Resource id #n' , where n is a number assigned to the resource. NULL '' (empty string) Example: <?php set_error_handler(function($errno, $errst... Results: bool(true) --------------------- strval: '1'...
Created by James on May 01, 2011 21:57:33    Last update: May 01, 2011 21:57:33
Both visibility:hidden and display:none hides an element in the DOM. But elements with visibility:hidden still takes up space, while display:none does not. Example (click the divs to hide or show): <!doctype html> <html> <head> <style t...
Created by James on May 01, 2011 21:40:35    Last update: May 01, 2011 21:47:18
It's a shame that double click events are always accompanied by click events in JavaScript. When you double click on an element, JavaScript fires two click events followed by one double click event. So if you attach both click and double click event handlers to the same element, both event handlers will be called when you double click. This is a utility function to alleviate the problem somewhat: <!doctype html> <html> <head> <script ... Note that there's still a possibility that both clicks and double clicks fired at the same time. This is because the timer used above may not be identical to the double click timer configured at the OS level. It's impossible to fix this problem in application code since each user may...
Created by James on April 30, 2011 21:28:06    Last update: May 01, 2011 13:00:35
This script moves a paragraph inside a div and then move it out. <!doctype html> <html> <head> <title>M...
Created by jinx on April 29, 2011 13:43:13    Last update: April 29, 2011 13:44:34
List of functions testing variable type: Function Description is_bool Finds out whether a variable is a boolean is_double Alias of is_float() is_float Finds whether the type of a variable is float is_int Find whether the type of a variable is integer is_integer Alias of is_int() is_long Alias of is_int() is_null Finds whether a variable is NULL is_numeric Finds whether a variable is a number or a numeric string is_object Finds whether a variable is an object is_real Alias of is_float() is_scalar Finds whether a variable is a scalar is_string Find whether the type of a variable is string Test code: <?php class A { } $a = ar... Output: var_dump: int(1) ------------------------- i...
Created by Dr. Xi on April 26, 2011 20:12:01    Last update: April 28, 2011 15:28:12
An XML schema is a definition of XML files, in XML. It plays the same role as old-time DTDs. Overall, an XML schema file looks like this: <schema attributeFormDefault = (qualified | u... The attribute meanings: targetNamespace : The name space targeted by the current schema definition. It can be any URI. id and version : For user convenience, the W3C spec defines no semantics for them. xml:lang : Natural language identifier defined by RFC 3306 . attributeFormDefault and elementFormDefault : Set default values for the form attribute for attribute and element declarations. blockDefault and finalDefault : Set default values for the block and final attributes for attribute and element declarations. The W3C defined some built-in datatypes . Examples of primitive datatypes are: string ,...
Created by jinx on April 27, 2011 20:47:41    Last update: April 27, 2011 20:48:21
Use the header function to send a raw HTTP header. It must be called before any output is sent (including spaces). <?php header('Content-type: text/xml'); ?>
Created by Dr. Xi on April 27, 2011 11:57:36    Last update: April 27, 2011 11:58:35
This is a sample struts-config.xml file for Struts 1.x . <?xml version="1.0" encoding="UTF-8"?> <!DO...
Created by jinx on April 26, 2011 21:52:10    Last update: April 26, 2011 21:52:10
PHP offers several ways to check the class type of an object instance at runtime: instanceof operator, is_a function, get_class function. Example: <?php class A { } class B { } ...
Previous  7 8 9 10 11 12 13 14 15 16 Next