课程: PHP with MySQL Essential Training: 1 The Basics
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Validations
(upbeat music) - [Instructor] Hopefully you did well with the challenge assignment to do page validations. In this movie, I'm going to show you the solution that I came up with. The first thing that I did, was I created a validate page function, which takes an associative array. That's all the page attributes that we're going to be working with later and I'm going to use an errors array to keep track of any problems. Then I'm going to go through, and I'm going to check and see various attributes. I'm going to check and see if subject ID is blank. If it is blank, then I'm going to say, "Subject cannot be blank." I'm going to do the same thing for menu name, I'm going to use the same kinds of things we had on subject that it's not blank. And also check that it's between two and 255 characters. Then for position, I'm going to check and make sure it's greater than zero, but less than 999. For visible, I'm going to make sure it's either a zero or a one. And then for the content, I'm just…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。