KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
How are dynamic pages served from server?
KevinM1 replied to Cupidvogel's topic in Application Design
Yup. One template can be used for an infinite amount of items. That's the power of dynamic sites. The same basic principle works for blogs, review sites, forums (including this one), and just about anything else you can think of. -
Great conversation, wrong board. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=357967.0
-
As been said, you store them in a database, along with other user info. The problem is that since you don't know how to use a database at all, it's hard to point you in the right direction. Teaching the fundamentals just isn't a good fit in a message board format. I suggest you look at some of the resources found in this thread, along with any other tutorials you can find that will illustrate how to create tables and run basic queries (these three tutorials may help) so you can grasp the basics. Trying to create a database design that does what you want will be nearly impossible unless you understand what's going on. That can only happen if you take the time to learn the basics.
-
Cookies can be erased/modified by the user. It's trivial to do it, too. Never use them for something like this.
-
Classes are NOT a stand-in for functions. Classes have a specific use.
-
Exactly right. The word 'global' is evil. Forget you ever saw it.
-
using call_user_func_array inside class method
KevinM1 replied to Hall of Famer's topic in PHP Coding Help
Oh really? Thats gonna work? o_o You tell me. -
using call_user_func_array inside class method
KevinM1 replied to Hall of Famer's topic in PHP Coding Help
Have you tried simplifying it to just $this->$method() ? -
So, do what gizmola suggested 10 times/in a loop.
-
I use Mint in a virtual machine as my open source development environment. I find it easier to use the command line for some things, like changing the permissions/owner of a file. Like thorpe says, there's a lot of power in the command line. If you're afraid of screwing stuff up, install your distribution of choice on a virtual machine. You can save a snapshot of the working OS, and restore back to it if you make a crippling mistake.
-
How are your tables structured?
-
How Does PHPFreaks Feel About the Hate PHP Often Gets as a Language?
KevinM1 replied to Masna's topic in Miscellaneous
It is a big part, but I think the biggest issue is the inconsistency with the language. I'm a mainly PHP programmer, but I can still see all of the silly inconsistencies with the language. Some function names have underscores while very similar ones do not. Some functions have "2" in the name, some have "to". Argument order is seemly random at times. It's not a huge deal for me, I work around it. My IDE shows me hints and such so that it's not a problem. But, it still gives the language bad reputation. Oh, definitely. It's one of those things that really shows the slapdash nature of some of the additions the language has had over time. -
This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=357681.0
-
How Does PHPFreaks Feel About the Hate PHP Often Gets as a Language?
KevinM1 replied to Masna's topic in Miscellaneous
I can't wait to try a functional language. F# looks pretty sweet. -
Yeah, you're definitely trying to run before you can walk. The simplest, most OO thing to do would be to extend/subclass Exception itself. Right now, you're wrapping it in another class for no real reason. Even though Exception is provided by PHP itself, it's a normal class. That will have you thinking in terms of the exception itself rather than the contortions you're trying to put it through. class SQLException extends Exception { private $severity; public function __construct($message = "", $severity = 0) { parent::__construct($message); $this -> severity = $severity; } public function getSeverity() { return $this -> severity; } } Just a basic example of how you could make your own Exception. Throwing/catching is the same as always: throw new SQLException("Something went wrong!"); . . . catch (SQLException $e) { // ... }
-
Social media intertwined with the forum
KevinM1 replied to algidDes702's topic in PHPFreaks.com Website Feedback
Yeah, I don't feel the need to link my Twitter and/or Facebook accounts to my PHPF account. I don't want to always be at another's beck-and-call. I don't want to develop a personal relationship with newbies. I've tried one-on-one online help a few times in the last few years, and it always ended badly. Why? Because the newbies - without fail - would become greedy. They expected me to be their primary source of information, not a supplementary one. I don't wish to repeat that experience. Above and beyond that, I want to keep some separation between my personal and professional lives. Web development is what I do. It's not who I am. -
How Does PHPFreaks Feel About the Hate PHP Often Gets as a Language?
KevinM1 replied to Masna's topic in Miscellaneous
PHP is solid. It's not without shortcomings. Unfortunately, because it's so easy to get results fast, a lot of PHP code is written horribly. That, IMO, is the largest contributing factor of PHP's negative reputation. -
Not to mention that Java and JavaScript are not related at all....
-
See also: http://www.phpfreaks.com/forums/index.php?topic=37442.0
-
But in PHP, procedural functions are used on a regular basis, even in OO applications. Some functions do not have OO alternatives, and thus must be used procedurally. This is because of PHP's history prior to PHP 5, wherein it was not at all object oriented. A lot of it's base still is procedural. Yes, I know. What I'm saying is that user defined functionality should attempt to fit one paradigm or the other. Making your own classes and function libraries to use in the same project is, IMO, not a good way to go. At the very least, to me, it's confusing. And, indeed, this is why static classes exist. They scratch that "I need a bit of generalized utility functionality without an object" itch while still being OO. It's not ideal, but it fills in an edge case like this better than a group of functions.
-
Especially considering that floating point is imprecise anyway.
-
Eh, it's not uncommon for very basic, very generalized functionality to be implemented as static classes. It's not necessarily the right way to do things, but it's a popular way of doing things. So popular that C# has a built-in mechanism for it: That's not a very fair comparison though. Isn't C# like hardcore OOP? It's not as hardcore as, say, Ruby. All of what PHP has for OOP is applicable. In this case, a static class in C# would be the following in PHP: class StaticExample { public static function blah() { // do something } public static function blah2($input) { // do something else } } Notice the similarities to my previous code example. The difference is just that C#'s compiler will complain if you declare a class as static, but attempt to implement non-static members. My overall point is that the idea of a class that has just static methods is common. Now, it needs to be used carefully, if at all, because it blows apart scope. That's why, in ASP.NET MVC, they're just used in views. The HTML helper class has a very specific job, can only be used in a certain context (they directly render HTML), and are only used at the end of the request -> response process. They can't pollute a model or controller. This is the list of classes that derive from the base HTML class, if you're curious. A static class is an option, if used properly.
-
Eh, it's not uncommon for very basic, very generalized functionality to be implemented as static classes. It's not necessarily the right way to do things, but it's a popular way of doing things. So popular that C# has a built-in mechanism for it: public static class Example { public static void Blah() { // do something } public static string Blah2(string input) { // do something else } } In that language, if you declare a class as being static, then all of its methods must be static. I believe the HTML helper classes in ASP.NET MVC are all static.