Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Hot answers tagged

3

Getters and setters So there is a getter for item (i.e. get_item()) - why not a getter (and setter) for the next property? If getters and setters are added, then those properties could be set to private visibility if deemed appropriate. Are you familiar with the PHP Standards Recommendations? While it is only a suggestion, you might find them helpful for ...


3

Trying to avoid duplicating any comments you have already had Why name the class "ST"? It's not very clear to another developer what a class called ST actually does Why extend EQ? Generally inheritance is use to make another class that provides the same functionality but more specialised, e.g. A "Car" might extend a class "Vehicle". I think it would be a ...


2

I recommend that you not store htmlspecialchars() values as a general practice. Of course you can if you wish, but I prefer to keep raw values in the db as a base representation of the data and then only manipulate the value when needed and in the manner required for the given task. You are (conditionally) calling slugify() twice on the $_GET["title"] value;...


1

There will be many, many ways to structure these permissions. I'll offer a pathway that doesn't totally abandon your original script. Don't bother writing out all of the super_admin permissions until the day when you actually have a no setting for them. Just write a simple condition on that single variable and an early return. Only store the yes and ...


1

Rather than generate the full array of elements that pathinfo() generously offers only to access one value, use the PATHINFO_EXTENSION flag/option (the second parameter) to only ask for what you need. For best efficiency, don't perform any unnecessary processes for disquaified incoming data. If you are going to declare errors at the start as an empty array, ...


1

Well, I just moved the part of code, which literally duplicates in both branches, above the condition. That's all. for the rest, I don't think there is anything significant could be made in the current paradigm. if ($_SERVER["REQUEST_METHOD"] === "POST") { $title = $_POST["title"]; $body = $_POST["body"]; $slug = slugify($title); if (empty(...


Only top voted, non community-wiki answers of a minimum length are eligible