Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on January 16, 2012 19:32:20    Last update: January 16, 2012 19:32:54
You can submit a form via Ajax by the jQuery Form Plugin . There are two main methods: ajaxForm : prepares a form for Ajax submit. Example: $('#myFormId').ajaxForm({ target: ... When the form is submitted, it is sent via Ajax. ajaxSubmit : submit a form via Ajax. Example: $('#myForm2').submit(function() { // i... jQuery Form Plugin is not in the core jQuery API, so you have to include an additional JS file: <head> <script type="text/javascript" ...
Created by Fang on November 02, 2011 16:40:10    Last update: November 02, 2011 16:40:10
Facelet taglib schema from JavaServer Faces Spec 2.0: <xsd:schema targetNamespace="http://java.sun.com/x...
Created by magnum on October 06, 2011 14:35:20    Last update: October 06, 2011 14:35:20
The longjmp function jumps to the line where setjmp was last called. In return, setjmp returns the value passed in as the second parameter to longjmp . #include <stdio.h> #include <stdlib.h> #incl... Result: $ ./longjmp val is 0 val is 1 --> val is ...
Created by magnum on September 24, 2011 13:14:37    Last update: September 28, 2011 18:08:35
There are two sides to an IP socket: the local side and the remote side: The getpeername function retrieves the peer address of the specified socket. #include <sys/socket.h> int getpeername(int soc... Example: struct sockaddr_in addr; socklen_t socklen = si... The getsockname function retrieves the locally-bound name of the specified socket. #include <sys/socket.h> int getsockname(int soc... Example: struct sockaddr_in addr; socklen_t socklen = si...
Created by magnum on September 11, 2011 19:46:09    Last update: September 11, 2011 19:46:09
A pair of C functions convert between an Internet address and a string (ASCII): #include <arpa/inet.h> /* * Returns a poin... However , these functions do not support IPv6. The new pair is: #include <arpa/inet.h> /* Convert a Internet ad... Examples: #include <sys/socket.h> #include <netinet/in.h>...
Created by magnum on September 11, 2011 19:00:28    Last update: September 11, 2011 19:00:28
Four C functions converts between network byte order (big-endian) and host byte order (big or little endian): #include <netinet/in.h> uint32_t htonl(uint... Function Does htons() host to network short htonl() host to network long ntohs() network to host short ntohl() network to host long
Created by voodoo on August 12, 2011 13:32:13    Last update: August 12, 2011 13:32:13
To get rid of this compilation warning, add: #include <stdlib.h>
Created by jinx on May 04, 2011 20:01:08    Last update: May 04, 2011 20:02:59
A static variable in PHP functions and methods keeps its value after the function/method scope is exited, just like static variables in C. A static variable in a class is a class variable, and is accessed by the class name. In the global scope, static has no special meaning. test.php: <?php include("test.inc"); include("... test.inc: <?php static $i = 0; $i++; echo __FILE__,... Output: E:\phpwork\test.inc included: 1 E:\phpwork\test...
Created by jinx on May 04, 2011 19:39:44    Last update: May 04, 2011 19:42:51
The function include includes the specified file multiple times, while include_once only includes the file once. This is a test: Create file test.php with contents: <?php for ($i = 0; $i < 5; $i++) { inclu... Create file test.inc with contents: <?php echo __FILE__, " included: $i\n"; ?> ... Run test.php , the output is: E:\phpwork\test.inc included: 0 E:\phpwork\test... Change include to include_once , only one line is printed: E:\phpwork\test.inc included: 0 You must use include_once to avoid duplicate includes in the case A includes B and C , but B and C both includes D . The relationship between require and require_once is the same.
Created by jinx on April 28, 2011 21:09:08    Last update: April 28, 2011 21:09:08
PHP global variables are defined outside of functions and classes. They are visible both in the current file and in any included/required files. Also, any global variables defined in required/included files are visible in the current file. But they are not visible in any functions or classes, unless specifically declared global . Test: Create file test.php : <?php ini_set('display_errors', 'stderr'); i... Create file test.inc : <?php echo '[', __FILE__, '] $a . $b = ', $... Run the PHP script in command line: php test.php 2>C:\tmp\stderr.out The result is: [C:\work\test.inc] $a . $b = ab [C:\work\test.p... stderr messages: PHP Notice: Undefined variable: b in C:\work\scra...
Previous  1 2 Next