patternphpMinor
Regex Tool in PHP
Viewed 0 times
regexphptool
Problem
I'm looking for feedback about anything and everything to do with this short program. For example, is there a risk in not sanitising the data, and if so, how would I do that given the need for non-alpha-numerics? How is the logic? Is my html up to date? Suggestions for styling? All input appreciated. I'm on a learning curve to become a professional, so need to be producing quality code.
Regex Tester
body{
font-family: arial;
font-size: 18px;
}
#wrapper{
width: 400px;
margin: 20px auto;
border: 2px solid blue;
}
h3{
text-align: center;
}
input, textarea{
font-size: inherit;
font-family: inherit;
box-sizing: border-box;
margin: 5px;
width:300px;
border-radius: 10px;
padding: 5px;
}
form{
width: 300px;
margin: 5px auto;
}
input[type=submit], #reset{
font-family: inherit;
font-size: 16px;
box-sizing: border-box;
margin: 5px 0;
width:100px;
border-radius: 10px;
padding: 2px;
}
#submit{
margin-left:5px;
}
#message{
margin: 10px;
}
Regex Tester
Enter a string:
Enter a pattern: ">
Solution
If you don't want to extend this site and you will not change the current page at all, then your code is completely ok. But you probably will therefore need to make it more flexible.
(use spl-autoload for your classes)
The next step is to learn the MVC pattern...
- Put css style and php code to different files. (see require_once)
- Build a class to sanitize _POST data and provide necessary data (and the reset mechanism)
- Build a class for executing
preg_match_all()and processing the output
(use spl-autoload for your classes)
The next step is to learn the MVC pattern...
Context
StackExchange Code Review Q#131628, answer score: 2
Revisions (0)
No revisions yet.