Để học bất cứ một ngôn ngữ lập trình nào những người mới bao giờ cũng phải trải qua 6 giai đoạn. 1. Quan niệm 2. Thử nghiệm 3. Trải nghiệm 4. Kiểm nghiệm 5. Chiêm nghiệm 6. Sáng tạo
Quan niệm
Hãy xác định nhiệm vụ học cho các bạn. Không có định hướng, không [...]
Có bạn hỏi làm sao tạo được các đường dẫn đẹp (URL Rewrite) như các trang trên mạng. Mình cũng tìm hiểu qua và xung phong viết 1 bài về nó vậy. Trước tiên chúng ta tìm hiểu cơ chế rewite:Rewrite Engine là một phần dịch vụ của Webserver được dùng để thay đổi URL(đường [...]
Other uses
Extracting Parts of a String
ereg() and eregi() have a feature that allows us to extract matches of patterns from strings (read the manual for details on how to use that). For instance, say we want do get the filename from a path/URL string -- this code would be all we need:
ereg("([^\/]*)$", $pathOrUrl, $regs);echo $regs[1];
Advanced [...]
Validating E-mail Addresses
Ok, let's take on e-mail addresses. There are three parts in an e-mail address: the POP3 user name (everything to the left of the '@'), the '@', and the server name (the rest). The user name may contain upper or lowercase letters, digits, periods ('.'), minus signs ('-'), and underscore signs ('_'). That's [...]
Validating Money Strings
Ok, we can now use what we've learned to work on something useful: a regular expression to check user input of an amount of money. A quantity of money can be written in four ways we can consider acceptable: "10000.00" and "10,000.00", and, without the cents, "10000" and "10,000". Let's begin with:
^[1-9][0-9]*$
That validates [...]
This site I'm working on relies heavily on user input through forms, and all that data needs to be checked before being sent a database. I knew PHP3's regular expression functions should solve my problem, but I didn't know how to form the regular expressions in the first place. What I needed were some sample [...]
Starting a Session
A session is a way to store information (in the form of variables) to be used across multiple pages. Unlike a cookie, specific variable information is not stored on the users computer. It is also unlike other variables in the sense that we are not passing them individually to each new page, [...]
PHP Visitor Tracking with Cookies
Cookies allow the webmaster to store information about the site visitor on their computer to be accessed again the next time they visit. One common use of cookies is to store your username and password on your computer so you don't need to login again each time you visit a website. [...]
« Trang trước