Thursday, December 18, 2008
Wednesday, December 17, 2008
Tuesday, July 29, 2008
Find syntax error without executing PHP file
Command to check PHP files for errors without executing
find /path/to/code -name *.php | xargs -n1 php -l
Wednesday, July 23, 2008
Thursday, July 10, 2008
Date Object in JavaScript
Date Object in JavaScript
Method | Description |
---|---|
Date() | Returns today's date and time |
getDate() | Returns the day of the month from a Date object (from 1-31) |
getDay() | Returns the day of the week from a Date object (from 0-6) |
getMonth() | Returns the month from a Date object (from 0-11) |
getFullYear() | Returns the year, as a four-digit number, from a Date object |
getYear() | Returns the year, as a two-digit or a three/four-digit number, depending on the browser. Use getFullYear() instead !! |
getHours() | Returns the hour of a Date object (from 0-23) |
getMinutes() | Returns the minutes of a Date object (from 0-59) |
getSeconds() | Returns the seconds of a Date object (from 0-59) |
getMilliseconds() | Returns the milliseconds of a Date object (from 0-999) |
getTime() | Returns the number of milliseconds since midnight Jan 1, 1970 |
getTimezoneOffset() | Returns the difference in minutes between local time and Greenwich Mean Time (GMT) |
getUTCDate() | Returns the day of the month from a Date object according to universal time (from 1-31) |
getUTCDay() | Returns the day of the week from a Date object according to universal time (from 0-6) |
getUTCMonth() | Returns the month from a Date object according to universal time (from 0-11) |
getUTCFullYear() | Returns the four-digit year from a Date object according to universal time |
getUTCHours() | Returns the hour of a Date object according to universal time (from 0-23) |
getUTCMinutes() | Returns the minutes of a Date object according to universal time (from 0-59) |
getUTCSeconds() | Returns the seconds of a Date object according to universal time (from 0-59) |
getUTCMilliseconds() | Returns the milliseconds of a Date object according to universal time (from 0-999) |
parse() | Takes a date string and returns the number of milliseconds since midnight of January 1, 1970 |
setDate() | Sets the day of the month in a Date object (from 1-31) |
setMonth() | Sets the month in a Date object (from 0-11) |
setFullYear() | Sets the year in a Date object (four digits) |
setYear() | Sets the year in the Date object (two or four digits). Use setFullYear() instead !! |
setHours() | Sets the hour in a Date object (from 0-23) |
setMinutes() | Set the minutes in a Date object (from 0-59) |
setSeconds() | Sets the seconds in a Date object (from 0-59) |
setMilliseconds() | Sets the milliseconds in a Date object (from 0-999) |
setTime() | Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 |
setUTCDate() | Sets the day of the month in a Date object according to universal time (from 1-31) |
setUTCMonth() | Sets the month in a Date object according to universal time (from 0-11) |
setUTCFullYear() | Sets the year in a Date object according to universal time (four digits) |
setUTCHours() | Sets the hour in a Date object according to universal time (from 0-23) |
setUTCMinutes() | Set the minutes in a Date object according to universal time (from 0-59) |
setUTCSeconds() | Set the seconds in a Date object according to universal time (from 0-59) |
setUTCMilliseconds() | Sets the milliseconds in a Date object according to universal time (from 0-999) |
toSource() | Represents the source code of an object |
toString() | Converts a Date object to a string |
toGMTString() | Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !! |
toUTCString() | Converts a Date object, according to universal time, to a string |
toLocaleString() | Converts a Date object, according to local time, to a string |
UTC() | Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time |
Tuesday, July 8, 2008
String Object in JavaScript
String Object in JavaScript
var str="Hello world!";
To get length of a string
var str_len = str.length;
To style strings
var str_big = str.big();
var str_small = str.small() ;
var str_bold = str.bold() ;
var str_italic = str.italics() ;
var str_blink = str.blink(); //(does not work in IE)
var str_fixed = str.fixed() ; //Displays a string as teletype text
var str_strike = str.strike() ;
var str_fc = str.fontcolor("Red") ;
var str_fs = str.fontsize(12) ;
var str_lc = str.toLowerCase() ;
var str_uc = str.toUpperCase() ;
var str_sub = str.sub() ;
var str_sup = str.sup() ;
var str_link = str.link("http://www.w3schools.com");
To get position of the first occurrence of a specified string value in a string
var str_pos = str.indexOf( "o" );
The lastIndexOf() method returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string.
var str_pos = str.lastIndexOf( "o" );
To use the match() method to search for a specified string value within a string and return the string value if found
var str_match = str.match( "world!" );
To use the replace() method to replace some characters with some other characters in a string.
var str_replace = str.replace( /world/, "JavaScript" );
The search() method is used to search a string for a specified value.
var str_search = str.search( /world/ );
The concat() method is used to join two or more strings.
var str_concat = str.concat("welcome", "to", "JavaScript");
The anchor() method is used to create an HTML anchor.
var str_anchor = str.anchor( "anchorName" );
The charAt() method returns the character at a specified position.
var str_charat = str.charAt( 1 ); //H
The charCodeAt() method returns the Unicode of the character at a specified position.
var str_charcode = str.charCodeAt( 1 ); //101
The fromCharCode() takes the specified Unicode values and returns a string.
var str_fromCharCode = String.fromCharCode( 72,69,76,76,79 ); //HELLO
The slice() method extracts a part of a string and returns the extracted part in a new string.
var str_slice = str.slice( 6 );
The split() method is used to split a string into an array of strings.
var str_split = str.split( " " );
The substr() method extracts a specified number of characters in a string, from a start index.
var str_substr = str.substr( 3 );
The substring() method extracts the characters in a string between two specified indices.
var str_substring = str.substring( 3 );
var str="Hello world!";
To get length of a string
var str_len = str.length;
To style strings
var str_big = str.big();
var str_small = str.small() ;
var str_bold = str.bold() ;
var str_italic = str.italics() ;
var str_blink = str.blink(); //(does not work in IE)
var str_fixed = str.fixed() ; //Displays a string as teletype text
var str_strike = str.strike() ;
var str_fc = str.fontcolor("Red") ;
var str_fs = str.fontsize(12) ;
var str_lc = str.toLowerCase() ;
var str_uc = str.toUpperCase() ;
var str_sub = str.sub() ;
var str_sup = str.sup() ;
var str_link = str.link("http://www.w3schools.com");
To get position of the first occurrence of a specified string value in a string
var str_pos = str.indexOf( "o" );
The lastIndexOf() method returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string.
var str_pos = str.lastIndexOf( "o" );
To use the match() method to search for a specified string value within a string and return the string value if found
var str_match = str.match( "world!" );
To use the replace() method to replace some characters with some other characters in a string.
var str_replace = str.replace( /world/, "JavaScript" );
The search() method is used to search a string for a specified value.
var str_search = str.search( /world/ );
The concat() method is used to join two or more strings.
var str_concat = str.concat("welcome", "to", "JavaScript");
The anchor() method is used to create an HTML anchor.
var str_anchor = str.anchor( "anchorName" );
The charAt() method returns the character at a specified position.
var str_charat = str.charAt( 1 ); //H
The charCodeAt() method returns the Unicode of the character at a specified position.
var str_charcode = str.charCodeAt( 1 ); //101
The fromCharCode() takes the specified Unicode values and returns a string.
var str_fromCharCode = String.fromCharCode( 72,69,76,76,79 ); //HELLO
The slice() method extracts a part of a string and returns the extracted part in a new string.
var str_slice = str.slice( 6 );
The split() method is used to split a string into an array of strings.
var str_split = str.split( " " );
The substr() method extracts a specified number of characters in a string, from a start index.
var str_substr = str.substr( 3 );
The substring() method extracts the characters in a string between two specified indices.
var str_substring = str.substring( 3 );
Thursday, July 3, 2008
Wednesday, July 2, 2008
Thursday, June 26, 2008
Math Object in JavaScript
Math Object in JavaScript
round() to round a number
Math.round(0.60) = 1;
Math.round(0.49) = 0;
random() to return a random number between 0 and 1
Math.random()
max() to return the number with the highest value of two specified numbers
Math.max(5,7) = 7
Math.max(-3,-5) = -3
min() to return the number with the lowest value of two specified numbers
Math.min(5,7) = 5
Math.max(-3,-5) = -5
round() to round a number
Math.round(0.60) = 1;
Math.round(0.49) = 0;
random() to return a random number between 0 and 1
Math.random()
max() to return the number with the highest value of two specified numbers
Math.max(5,7) = 7
Math.max(-3,-5) = -3
min() to return the number with the lowest value of two specified numbers
Math.min(5,7) = 5
Math.max(-3,-5) = -5
Wednesday, June 18, 2008
Window Object in JavaScript
Window Object in JavaScript
Some Syntax...
To get default text in the statusbar of the window
var status = window.defaultStatus;
To get text in the statusbar of a window
var status = window.status;
To get window name
var winName = window.name;
To remove focus from the current window
window.blur();
To set focus to the current window
window.focus();
To get the outer height of a window in pixels
var outerheight= window.outerheight;
To get the outer width of a window in pixels
var outerwidth= window.outerwidth;
To get reference to the current window
window.self;
To get topmost ancestor window
window.top;
To moves a window a specified number of pixels relative to its current coordinates
window.moveBy(x,y);
To moves a window's left and top edge to the specified coordinates
window.moveTo(x,y);
To resize a window by the specified pixels
resizeBy(width,height);
To resize the window to the specified width and height
resizeTo(width,height);
To scroll the content by the specified number of pixels
scrollBy(xnum,ynum);
To scrolls the content to the specified coordinates
scrollTo(xpos,ypos);
To print the contents of the current window
window.print();
To open a new browser window
window.open(URL,name,specs,replace);
To close the current window
window.close();
To check window has been closed
var closed = window.closed;
Regular Expressions in JavaScript
Regular Expressions can be used in the following JavaScript String Methods.
- string.match()
- string.search()
- string.replace()
- string.split()
Trim in JavaScript
To Trim space in a word
Left Trim Function to trim the space in the left side of the string
function ltrim ( s ){
return s.replace( /^\s*/, "" );
}
Right Trim Function to trim the space in the right side of the string
function rtrim ( s ){
return s.replace( /\s*$/, "" );
}
Trim Function to trim the space in the string
function trim(s) {
var temp = s;
return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}
Monday, June 16, 2008
Document Object in JavaScript
Document Objects in JavaScript
To write in document
document.write("Hello World!");
document.writeln("Hello World!");
The title of the document
var title = document.title;
The URL of this document
var url = document.URL;
The referrer of this document
var referrer = document.referrer;
The domain name for this document
var domain = document.domain;
To get element object by ID
var obj = document.getElementById("id_name");
To get element object by Name
var obj = document.getElementsByName("tag_name");
To get element object by TagName
var obj = document.getElementsByTagName("tag_name");
Number of anchors in this document
var cnt_anchor = document.anchors.length;
Number of Form in this document
var cnt_frm = document.forms.length;
Number of images in this document
var cnt_img = document.images.length;
The cookie property sets or returns all cookies associated with the current document.
var cookie = document.cookie;
The lastModified property returns the date and time the document was last modified.
var lastmodified = document.lastModified;
Screen Object in JavaScript
To detect details about the client's screen
Screen resolution:
document.write(screen.width + "*" + screen.height);
Available view area:
document.write(screen.availWidth + "*" + screen.availHeight);
Color depth:
document.write(screen.colorDepth);
Buffer depth:
document.write(screen.bufferDepth);
DeviceXDPI:
document.write(screen.deviceXDPI);
DeviceYDPI:
document.write(screen.deviceYDPI);
LogicalXDPI:
document.write(screen.logicalXDPI);
LogicalYDPI:
document.write(screen.logicalYDPI);
FontSmoothingEnabled:
document.write(screen.fontSmoothingEnabled);
PixelDepth:
document.write(screen.pixelDepth);
UpdateInterval:
document.write(screen.updateInterval);
Events in JavaScript
What is Event in JavaScript...???
Every time anything happens to a page or an object in the page an event is triggered.
Here few examples of events.
- onload
- onChange
- onMouseOver
- onResize
- onError
- onUnload
- onSubmit
- onAbort
- onClick
We can use these events to trigger our scripts, or more correctly, to trigger a function.
Sunday, June 15, 2008
How to get window title in JavaScript...???
To Get Window Title in JavaScript
var title = document.title;
How to get host name in JavaScript?
To get host name in JavaScript - HTTP_HOST
var hostname = window.location.hostname
Friday, June 13, 2008
Size attribute in CSS
Relative Units
em ems, the height of the element's font
ex x-height, the height of the letter "x"
px pixels, relative to the canvas resolution
Absolute Units
in inches; 1 inch = 2.54cms
cm centimeters; 1cm = 10mm
mm millimeters
pt points; 1pt = 1/72 inch
pc picas; 1pc = 12pts
How to get client information in JavaScript...???
How to gather information about your users environment including their computer platform, operating system, browser details, etc. ?
Application Code Name
var codeName = navigator.appCodeName;
Application Name
var appName = navigator.appName;
Application Version
var appVersion = navigator.appVersion;
User Language and Language
var userLanguage = navigator.userLanguage;
var language = navigator.language;
Platform
var appName = navigator.platform;
User Agent
var userAgent = navigator.userAgent;
Java Enabled
var javaEnabled = navigator.javaEnabled();
To check cookies are enabled in the browser.
navigator.cookieEnabled
CPU class of the browser's system
var cpuClass = navigator.cpuClass;
To get boolean status of system mode.
navigator.onLine;
Browser Version
var version = parseInt(navigator.appVersion,10);
Wednesday, June 11, 2008
Disable Page Printing...
This is a Microsoft only solution and you should include these Attributes in your BODY Tag...
<body onBeforePrint="document.body.style.display='none'"; onAfterPrint="document.body.style.display='';">
This is a CSS cross-browser solution which should be included as a separate section in the HEAD of your page...
<style media='print'>
BODY { display:none;}
</style>
Disable Browser Cache...
Include this META Tag in the HEAD section of your page along with the other META Tags...
microsoft/mozilla/netscape browsers all require this meta tag
<meta http-equiv='Pragma' content='no-cache'>
microsoft browsers require this additional meta tag as well
<meta http-equiv='Expires' content='-1'>
and then include this second HEAD section between the BODY closing Tag and HTML closing Tag...
add this extra head section if you find your pages are still being cached in some browsers
</body>
<head>
<meta http-equiv='Pragma' content='no-cache'>
</head>
</html>
JavaScript Disabled...
Add this Markup to the HEAD section of your page, immediately below the META Tags ...
If JavaScript Disabled page will be redirected to given URL
<noscript>
<meta http-equiv='REFRESH' content='0;URL=redirect-error-page.html'>
</noscript>
Disable Copy/Paste ...
Add these attributes to the BODY Tag to disable copy/paste everywhere on the page...
<body ondragstart='return false' onselectstart='return false'>
or better still add this script to the JavaScript section in the HEAD of your page...
" document.body.ondragstart = 'return false' ; "
" document.body.onselectstart = 'return false'; "
Disable Image Toolbar
Use this Markup to disable Image Toolbar for all images on the page ...
<meta http-equiv='imagetoolbar' content='no'>
Use this Markup to disable Image Toolbar for individual images ...
<img src='imagename.gif' width='250' height='250' galleryimg='no'>
Disable Right Click
Add this attribute to the BODY Tag to disable the context menu everywhere on the page ...
<body oncontextmenu='return false'>
Add this Attribute to an IMG Tag to disable the context menu for individual images ...
<img src='imagename.gif' width='250' height='250' oncontextmenu='return false'>
Tuesday, June 10, 2008
Monday, June 9, 2008
Subscribe to:
Posts (Atom)