Showing posts with label html. Show all posts
Showing posts with label html. Show all posts

Saturday, August 3, 2013

HTML: Special Characters

HTML Entities and/or ISO Latin-1 codes can be placed in source code like any other alphanumeric characters to produce special characters and symbols that cannot be generated in HTML with normal keyboard commands.



For example, to render Düsseldorf the HTML source should read
Düsseldorf or Düsseldorf
While many similar lists are available on the Web (run your favorite search engine using "ISO Latin" or "HTML Entities"), none I've seen account for the standard character sets of different operating systems (e.g. Windows vs. DOS vs. Macintosh, etc.); this list should produce the same results on all platforms.
PunctuationHTML Entity
(case sensitive)
ISO Latin-1 codename or meaning
––en dash
——em dash
¡¡¡inverted exclamation
¿¿¿inverted question mark
"""quotation mark
““left double curly quote
””right double curly quote
''apostrophe (single quote)
‘‘left single curly quote
’’right single curly quote
«

»
«

»
«

»
guillemets (used as quotation marks in some languages, e.g., French)
  
(Its there, but you can't see it!)
  non-breaking space
Symbols
&&&ampersand
¢¢¢cent
©©©copyright
÷÷÷divide
>>>greater than
<&lt;&#60;less than
µ&micro;&#181;micron
·&middot;&#183;middle dot
&para;&#182;pilcrow (paragraph sign)
±&plusmn;&#177;plus/minus
&euro;&#8364;Euro
£&pound;&#163;British Pound Sterling
®&reg;&#174;registered
§&sect;&#167;section
&trade;&#153;trademark
¥&yen;&#165;Japanese Yen
Diacritics
á

Á
&aacute;

&Aacute;
&#225;

&#193;
lower-case "a" with acute accent

upper-case "A" with acute accent
à

À
&agrave;

&Agrave;
&#224;

&#192;
lower-case "a" with grave accent

upper-case "A" with grave accent
â

Â
&acirc;

&Acirc;
&#226;

&#194;
lower-case "a" with circumflex

upper-case "A" with circumflex
å

Å
&aring;

&Aring;
&#229;

&#197;
lower-case "a" with ring

upper-case "A" with ring
ã

Ã
&atilde;

&Atilde;
&#227;

&#195;
lower-case "a" with tilde

upper-case "A" with tilde
ä

Ä
&auml;

&Auml;
&#228;

&#196;
lower-case "a" with diaeresis/umlaut

upper-case "A" with diaeresis/umlaut
æ

Æ
&aelig;

&AElig;
&#230;

&#198;
lower-case "ae" ligature

upper-case "AE" ligature
ç

Ç
&ccedil;

&Ccedil;
&#231;

&#199;
lower-case "c" with cedilla

upper-case "C" with cedilla
é

É
&eacute;

&Eacute;
&#233;

&#201;
lower-case "e" with acute accent

upper-case "E" with acute accent
è

È
&egrave;

&Egrave;
&#232;

&#200;
lower-case "e" with grave accent

upper-case "E" with grave accent
ê

Ê
&ecirc;

&Ecirc;
&#234;

&#202;
lower-case "e" with circumflex

upper-case "E" with circumflex
ë

Ë
&euml;

&Euml;
&#235;

&#203;
lower-case "e" with diaeresis/umlaut

upper-case "E" with diaeresis/umlaut
í

Í
&iacute;

&Iacute;
&#237;

&#205;
lower-case "i" with acute accent

upper-case "I" with acute accent
ì

Ì
&igrave;

&Igrave;
&#236;

&#204;
lower-case "i" with grave accent

upper-case "I" with grave accent
î

Î
&icirc;

&Icirc;
&#238;

&#206;
lower-case "i" with circumflex

upper-case "I" with circumflex
ï

Ï
&iuml;

&Iuml;
&#239;

&#207;
lower-case "i" with diaeresis/umlaut

upper-case "I" with diaeresis/umlaut
ñ

Ñ
&ntilde;

&Ntilde;
&#241;

&#209;
lower-case "n" with tilde

upper-case "N" with tilde
ó

Ó
&oacute;

&Oacute;
&#243;

&#211;
lower-case "o" with acute accent

upper-case "O" with acute accent
ò

Ò
&ograve;

&Ograve;
&#242;

&#210;
lower-case "o" with grave accent

upper-case "O" with grave accent
ô

Ô
&ocirc;

&Ocirc;
&#244;

&#212;
lower-case "o" with circumflex

upper-case "O" with circumflex
ø

Ø
&oslash;

&Oslash;
&#248;

&#216;
lower-case "o" with slash

upper-case "O" with slash
õ

Õ
&otilde;

&Otilde;
&#245;

&#213;
lower-case "o" with tilde

upper-case "O" with tilde
ö

Ö
&ouml;

&Ouml;
&#246;

&#214;
lower-case "o" with diaeresis/umlaut

upper-case "O" with diaeresis/umlaut
ß&szlig;&#223;ess-tsett
ú

Ú
&uacute;

&Uacute;
&#250;

&#218;
lower-case "u" with acute accent

upper-case "U" with acute accent
ù

Ù
&ugrave;

&Ugrave;
&#249;

&#217;
lower-case "u" with grave accent

upper-case "U" with grave accent
û

Û
&ucirc;

&Ucirc;
&#251;

&#219;
lower-case "u" with circumflex

upper-case "U" with circumflex
ü

Ü
&uuml;

&Uuml;
&#252;

&#220;
lower-case "u" with diaeresis/umlaut

upper-case "U" with diaeresis/umlaut
ÿ&yuml;&#255;lower-case "y" with diaeresis/umlaut
´

`
&#180;

&#96;
acute accent with no letter

grave accent/reversed apostrophe with no letter

Notes:
  1. The &quot; entity was mistakenly omitted from the HTML 3.2 specification. While use of &quot; generates error reports when validating against 3.2, browsers have continued to recognize the entity and its use is generally safe (sticklers may wish to use &#34; instead). The omission has been corrected in the HTML 4.0 specification.
  2. The non-breaking space (&nbsp; or &#160;) can be used not only to prevent the separation of words by line wraps, but also to force a space equal in size to a keyboard/spacebar space (useful for indentation or wider word separation) or to "hold" space in the empty cell of a table (as in the table above).
  3. The middle dot (&middot; or &#183;) can be used as a bullet and embedded anywhere in text. Because it is equal in size to a period, however, it may be necessary to apply <B> </B> or tags to enhance its graphic effect (use of <FONT SIZE="x"> </FONT> or <BIG> </BIG> elements is not recommended, as these will alter the character's vertical spacing relative to other characters in the same line).

Thursday, July 18, 2013

How to create a 301 Redirect

301 Redirect

301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It's not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently".
You can Test your redirection with Search Engine Friendly Redirect Checker
Below are a Couple of methods to implement URL Redirection via code and htaccess redirect


IIS Redirect

  • In internet services manager, right click on the file or folder you wish to redirect
  • Select the radio titled "a redirection to a URL".
  • Enter the redirection page
  • Check "The exact url entered above" and the "A permanent redirection for this resource"
  • Click on 'Apply'

ColdFusion Redirect

<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com"> 

PHP Redirect

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?> 

ASP Redirect

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%> 

ASP .NET Redirect

<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com");
}
</script>

JSP (Java) Redirect

<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%> 

CGI PERL Redirect

$q = new CGI;
print $q->redirect("http://www.new-url.com/"); 


Ruby on Rails Redirect

def old_action
headers["Status"] = "301 Moved Permanently"
redirect_to "http://www.new-url.com/"
end

Redirect Old domain to New domain using htaccess redirect

Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Please REPLACE www.newdomain.com in the above code with your actual domain name.
In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

Redirect to www using htaccess redirect

Create a .htaccess file with the below code, it will ensure that all requests coming in to domain.com will get redirected to www.domain.com
The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Please REPLACE domain.com and www.newdomain.com with your actual domain name.
Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

How to Redirect HTML

Please refer to section titled 'How to Redirect with htaccess', if your site is hosted on a Linux Server and 'IIS Redirect', if your site is hosted on a Windows Server.

Tuesday, July 9, 2013

Chú thích trong: HTML, CSS, PHP, Javascript, SQL & ASP

Lúc viết code thì điều cần thiết là chú thích đoạn code mình viết ra là gì? Nhưng rất rất nhiều bạn không biến đến điều này, thậm chí là không biết ký tự chú thích trong ngôn ngữ mình dùng bắt đầu và kết thúc như thế nào.


Dưới đây là bảng danh sách mô tả cho các ngôn ngữ cơ bản của bộ môn Thiết kế website.
Language Single/Multi-Line Start with End with Example
HTML Single & Multi-Line <!– –> <!– This is an HTML Comment –>
PHP Single Line // // This is a PHP Comment
PHP Mutli-Line /* */ /* This is a PHP Comment */
JavaScript Single Line // // This a JScript Comment
JavaScript Mutli-Line /* */ /* This is a JavaScript Comment */
CSS Single & Multi-Line /* */ /*This is a CSS comment*/
ASP Single & Multi-Line ‘ This is an ASP Comment
SQL Single & Multi-Line { } { This is an SQL Comment }
SQL Single – (Two dashes) – This is an SQL Comment

Thursday, July 4, 2013

Vì sao bạn chọn PHP làm bạn đồng hành để thiết kế website?

Khác với mô hình lập trình Desktop thông thường, lập trình trên môi trường web chủ yếu dựa vào mô hình Client-Server và giao thức HTTP để làm việc. Hiện tại, có khá nhiều ngôn ngữ cho phép chúng ta lập trình web như Java, .NET, PHP, Perl, Python, Ruby on Rails…Mỗi ngôn ngữ đều có những ưu và khuyết điểm riêng. Nội dung của bài viết này sẽ đi vào một số điểm nổi bật của PHP và một số nhân tố khiến PHP ngày càng trở nên phổ biến như ngày nay.
Tôi chọn PHP vì:

Mã nguồn mở

  • Có lẽ nhiều bạn cũng biết PHP là một sản phẩm mã nguồn mở (Open-source) nên việc cài đặt và tùy biến PHP là miễn phí và tự do.
  • Vì có ưu thế nguồn mở nên PHP có thể được cài đặt trên hầu hết các Web Server thông dụng hiện nay như Apache, IIS…

Tính Cộng đồng của PHP

  • Là một ngôn ngữ mã nguồn mở cùng với sự phổ biến của PHP thì cộng đồng PHP được coi là khá lớn và có chất lượng.
  • Với cộng đồng phát triển lớn, việc cập nhật các bản vá lỗi phiên bản hiện tại cũng như thử nghiệm các phiên bản mới khiến PHP rất linh hoạt trong việc hoàn thiện mình.
  • Cộng đồng hỗ trợ, chia sẽ kinh nghiệm của PHP cũng rất dồi dào. Với rất nhiều diễn đàn, blog trong và ngoài nước nói về PHP đã khiến cho quá trình tiếp cận của người tìm hiểu PHP được rút ngắn nhanh chóng.

Thư viện phong phú

  • Ngoài sự hỗ trợ của cộng đồng, thư viện script PHP cũng rất phong phú và đa dạng. Từ những cái rất nhỏ như chỉ là 1 đoạn code, 1 hàm (PHP.net…) cho tới những cái lớn hơn như Framework (Zend, CakePHP, CogeIgniter, Symfony…) ,ứng dụng hoàn chỉnh (Joomla, WordPress, PhpBB…)
  • Với thư viện code phong phú, việc học tập và ứng dụng PHP trở nên rất dễ dàng và nhanh chóng. Đây cũng chính là đặc điểm khiến PHP trở nên khá nổi bật và cũng là nguyên nhân vì sao ngày càng có nhiều người sử dụng PHP để phát triển web.

Hỗ trợ kết nối nhiều hệ cơ sở dữ liệu

  • Nhu cầu xây dựng web có sử dụng cơ sở dữ liệu là một nhu cầu tất yếu và PHP cũng đáp ứng rất tốt nhu cầu này. Với việc tích hợp sẵn nhiều Database Client trong PHP đã làm cho ứng dụng PHP dễ dàng kết nối tới các hệ cơ sở dữ liệu thông dụng.
  • Việc cập nhật và nâng cấp các Database Client đơn giản chỉ là việc thay thế các Extension của PHP để phù hợp với hệ cơ sở dữ liệu mà PHP sẽ làm việc.
  • Một số hệ cơ sở dữ liệu thông dụng mà PHP có thể làm việc là: MySQL, MS SQL, Oracle, Cassandra…

Lập trình hướng đối tượng

  • Ngày nay, khái niệm lập trình hướng đối tượng (OOP) đã không còn xa lạ với lập trình viên. Với khả năng và lợi ích của mô hình lập trình này nên nhiều ngôn ngữ đã triển khai để hỗ trợ OOP.
  • Từ phiên bản PHP 5, PHP đã có khả năng hỗ trợ hầu hết các đặc điểm nổi bật của lập trình hướng đối tượng như là Inheritance, Abstraction, Encapsulation, Polymorphism, Interface, Autoload…
  • Với việc ngày càng có nhiều Framework và ứng dụng PHP viết bằng mô hình OOP nên lập trình viên tiếp cận và mở rộng các ứng dụng này trở nên dễ dàng và nhanh chóng.

Tính Bảo mật

  • Bản thân PHP là mã nguồn mỡ và cộng đồng phát triển rất tích cực nên có thể nói PHP khá là an toàn.
  • PHP cũng cung cấp nhiều cơ chế cho phép bạn triển khai tính bảo mật cho ứng dụng của mình như session, các hàm filter dữ liệu, kỹ thuật ép kiểu, thư viện PDO (PHP Data Object) để tương tác với cơ sở dữ liệu an toàn hơn.
  • Kết hợp với các kỹ thuật bảo mật ở các tầng khác thì ứng dụng PHP sẽ trở nên chắc chắn hơn và đảm bảo hoạt động cho website.

Khả năng mở rộng cho PHP

  • Bằng việc xây dựng trên nền ngôn ngữ C và là mã nguồn mở nên khả năng mở rộng cho ứng dụng PHP có thể nói là không có giới hạn.
  • Với thư viện phong phú và khả năng mở rộng lớn, ứng dụng PHP có thể tương tác với hầu hết các loại ứng dụng phổ biến như xử lý hình ảnh, nén dữ liệu, mã hóa, thao tác file PDF, Office, Email, Streaming…
  • Bạn hoàn toàn có thể tự xây dựng cho mình các Extension để tối ưu, bổ sung các chức năng cho PHP cũng như tối ưu luôn Core của PHP để phục vụ cho các mục đích mở rộng website của mình.

Liệu biết PHP là đủ?
Như nhiều bạn lập trình viên có khả năng học khá nhiều ngôn ngữ lập trình nói chung và ngôn ngữ lập trình web nói riêng thì việc chỉ biết mỗi PHP thì có lẽ chưa “thỏa mãn”. Biết một ngôn ngữ chưa hẳn là ít, nếu bạn chú tâm và đào sâu thì mỗi ngôn ngữ luôn có những tầng khác nhau để khám phá. Không sợ học hết, chỉ sợ học không nổi mà thôi!

Nói đi cũng phải nói lại, nếu chỉ biết mỗi PHP thì thật sự bạn khó có khả năng triển khai 1 website. Bởi vì trong một hệ thống website, Coding PHP chỉ là một mảng nhỏ trong khâu sản xuất web mà thôi. Bạn cần phải trang bị một số kiến thức khác trong công nghệ web như : HTML, CSS, Javascript, SEO, UML, Database, Networking…để đảm bảo bạn nắm được những gì sẽ xảy ra trong quá trình làm web vì nó sẽ rất có ích cho bạn khi triển khai PHP.

Như vậy có nghĩa là học lập trình web thì bạn phải vừa học theo chiều sâu và học theo chiều rộng. Ngôn ngữ lập trình web phía Server (PHP) thì học càng sâu càng tốt và các công nghệ của web thì tìm hiểu càng rộng càng tốt. Có như vậy bạn mới có một cái nhìn toàn diện hơn về ứng dụng web và dễ dàng hoàn thiện website.

Môi trường làm việc, thị trường & tương lai của PHP

Để học tập và nghiên cứu PHP thì triển khai môi trường để tiến hành rất dễ. Bạn có thể cài các bộ ứng dụng đầy đủ để tạo mô hình Client-Server ngay trên máy của mình để học (AppServ, WAMP, XAMPP…) .
Nếu bạn không muốn code từ đầu thì có thể nghiên cứu các Framework PHP để phát triển ứng dụng trên đó như là Zend, CakePHP, CodeIgniter…

Như hầu hết các ngôn ngữ lập trình hiện đại khác, bạn cũng có thể sử dụng các IDE để phát triển ứng dụng PHP như Zend Studio, Nusphere PhpED, NetBeans…Với các tính năng nổi bật như là Code & Syntax Highlighting, Auto-Complete, Project Manager, Code Navigator, Debug…thì việc code PHP sẽ trở nên dễ dàng và nhanh chóng hơn.

Với việc ngày càng có nhiều ứng dụng lớn viết bằng PHP, sự đa dạng trong ứng dụng và Framework làm cho thị trường và tương lai dành cho các bạn yêu thích PHP là rất lớn. Ngoài ra, bạn có thể thử sức với chứng chỉ ZCE của Zend trong lĩnh vực PHP. Rất nhiều công ty đang chọn PHP làm ngôn ngữ phát triển website cho khách hàng cũng như sản phẩm của riêng họ nên việc hiểu biết và chuyên sâu về công nghệ web nói chung và chuyên sâu về PHP nói riêng sẽ là một lợi thế rất lớn cho các bạn.

(Bài viết được sưu tầm trên internet)