Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. It's so strange seeing many of the staff with new avatars. Some of you are actually people!
  2. What you want to do is best served with just straight CSS. You can detect the size of the screen within CSS using media queries, which sort of function like an if/else. More info: http://mobile.smashi...f-your-website/
  3. It's not as simple as "I'm never going to support old browsers" or "I'm always going to support old browsers." Instead, there's an intersection between the cost of supporting those old browsers and the amount of revenue that population brings in. To blindly say, "Fuck 'em. Update or go screw yourself," might be noble, and it might get you internet cred, but from a business POV it's shortsighted. It's intentionally dismissing a potential pool of revenue. Now, maybe you can afford to not cater to that population. Fine. Many developers cannot ignore them, however. Keep in mind, no one is saying "IE 6/7 is teh bestest!!!!11!" What we're saying is, although they suck to develop for, ignoring them is often more costly than working around their limitations. Now, developers should keep making a big stink about how badly they suck, but they need to do it in a positive way. Instead of just giving the middle finger to the people who have the old browsers, give them a bare-bones but functional site with a hint of what they could experience if they upgraded (along with info about how to upgrade, links, and reassurances that upgrading won't kill their PC). Entice them to switch rather than ignore them and deride them from on high.
  4. Yeah, I'm not going to show you how to continue to use 'global'. Instead, simply change your function definition's first line to: function validate($errorArray, $Validation) And remove from within there: global $errorArray; global $Validation; --- Okay, now, at the beginning of your script, remove: global $added; $added = " "; and replace it with: $added = validate($errorArray, $Validation); --- Finally, in your HTML/display part, replace: <?php echo $added; ?> With: <?php if(isset($added)) echo $added; ?> That should (hopefully) cover it. Keep in mind, that none of this is tested, so it might not work right off the bat. Kinda written off the cuff....
  5. Don't use 'global'. Ever. Functions have an argument list for a reason. Rewrite your function(s) to accept arguments, and in the code that invokes the function(s), pass in the proper parameters. 'global' is the single worst part of PHP, mostly because every crap book and tutorial still floating around since 2004 uses it exclusively, and thus there is a ton of bad code that relies on it as well. If you have a resource that uses 'global' to pass in parameters, burn/destroy it for the good of us all.
  6. They're generally a bad idea. They're an anti-pattern - something that looks good initially, but quickly makes one's code harder to maintain. By design they're global, which blows apart encapsulation. The standard examples of a db connection or config file reader/registry/whatever tend to miss the point. In PHP (and other languages), objects are passed by reference (in PHP a reference is technically just an alias, but it acts about 99% like a real reference for our use). This means that composition and argument passing is cheap in terms of memory management. Multiple objects can hold a shared reference to another without much of a penalty. And since most base application resources (db connections, config data) are created/loaded before the app does real work, there's generally no reason why they can't be passed into the objects that need them. So, one bootstrapped db connection can be passed around to the many objects that require it. That's essentially what Dependency Injection is, and it's why it's a far better alternative. Just about anywhere you see someone suggest a Singleton for web programming, what they really should do is implement DI to make their lives easier without blowing apart encapsulation and scope.
  7. Think of an API as a set of functions. Just as each function in PHP has a signature*, so do API calls. *A function signature consists of: the function's name, the type and number of its arguments, and its return type. You can see how this looks in the PHP online documentation. An example: string substr ( string $string , int $start [, int $length ] ) This tells us that the substr function has two required arguments - $string (which is a string) and $start (which is an integer) - and one optional argument - $length (which is also an integer). We can also see that the function returns a string. An API is similar, except it uses HTTP. You can have a signature like: mixed object - getuser/{id:int} This would mean that there's an API call named 'getuser' that takes an integer id as a parameter, and returns a user object. Keep in mind that that's just the call's signature. Invoking it would mean using the URL example.com/getuser/23 or something along those lines. Its return data would likely be a JSON object, or maybe some XML that could be parsed. Why that and not raw PHP? Because the whole idea of an API is that any service can make requests. Because of that, the data sent back to the service needs to be platform agnostic. Good APIs tend to be RESTful, which is really just a fancy way of saying they use HTTP verbs (like GET and POST) according to the HTTP spec. So, GET for retrieving data, POST for adding data, DELETE for removing data, etc. Hope this helps!
  8. I'm a bit split on the update issue. I agree with Josh in that I think users should be able to update (or not) when they want. That said, IE needs to inform the user when an update is available, and the benefits to updating. A lot of people don't update because they don't realize it's an option. Shit, there is still a not-insignificant number of people who are certain that Windows Update will irrevocably damage their PC because they read it on Facebook/a fake chain letter/heard it from their grandson/nephew.
  9. I know i don't just mean the look or cosmetic part which is all CSS and HTML i just mean for someone who creates websites in their spare time would it help them do A LOT MORE if they knew PHP or are there so many available options out there today for people without PHP knowledge that it really isn't needed unless you are seriously into making websites. This is still a bit vague. There are options for people who don't want to write code themselves. It comes in the form of pre-packaged software, like WordPress or Joomla. They're full-featured options that allow one to install plugins and various themes to get it to work and look the way they want. As a coder, I find pre-made software to be a bit limiting, generally because I've yet to find one that does things exactly how I'd like, so I tend to have to go under the hood and tweak code anyway. In a more general sense, if you want a site to do more than just sit there and look pretty, you'll need to use some sort of back end processing. PHP is the most popular and readily available choice because: It's free. It's easy to learn. It's easy to install (if you're in charge of what's on the server). It's installed on just about every web host on the planet, both linux and Windows. One need look no further than Facebook to see it's continued relevance. All that said, there are other viable options out there. On the linux side of things, both Ruby on Rails and Python are popular choices. Things are more limited/dire on the Windows side, with only ASP.NET MVC as a real viable choice (let's not talk about ASP.NET webforms....). So, really, the answer to the question depends on what you want to do, and how you want to progress. There's nothing wrong with using pre-made software. There's nothing wrong with writing everything from scratch. Both have pros and cons. Language choice is largely irrelevant as all those I listed allow you to do the same thing, but in different ways.
  10. IE 8 was solid. IE 9+ are fine browsers. As a company, Microsoft has embraced HTML 5. It's what the Metro interface and apps use for their display layer (along with JavaScript and CSS). It allows them to save money (goodbye Silverlight, and other entirely proprietary solutions) while making it easier for devs to jump over to the dark side. The Microsoft of today is not the Microsoft of the early-to-mid 2000's. Yes, they're still lumbering, slow to change, and make questionable decisions (I think Win8 is going to bomb spectacularly), but they're not completely horrible. Their next big fight will likely be in the online marketplace. The current rules would make it difficult/impossible for a distributor like Steam to get on a Win8 system, and MS has been toying with perpetual license renewals for staple software like Office to the cost of $99/year. That's where the old, evil, "are you friggin' kidding me?" Microsoft has appeared as of late. But, yeah, on the browser/web development side, MS has really modernized and evolved.
  11. Good work, Philip & Co!
  12. Bullshit. And, quite frankly, I'm getting tired of you spamming the board with your unfounded "OOP is the bestest" tripe*. Consider this a warning: any further posts that merely cheerlead OOP will be considered trolling and dealt with as such. *Lest you think I don't 'get' OOP, I use it every day, both in PHP and C#.
  13. This should just be "Class itself and its children." http://php.net/manual/en/language.oop5.visibility.php Huh. That's odd, as generally one wouldn't ever need to have a parent access a child's protected member (okay, that sounds dirty). The whole point of protected is to say "From this point on in the class hierarchy, only me and my children can see this."
  14. This should just be "Class itself and its children."
  15. If there are any other users on the system, you can always finger them (yes, 'finger' is a command).
  16. I don't really like that. The code will run and work fine as it stands, except it won't be a real session. Plus, it's not immediately obvious that this snippet of code is actually the start of an application. Maybe I'm just nitpicking now. I think it's a fair crit. Given how easy (and ubiquitous) it is to enter/exit PHP, it's hard to tell if that snippet is an entire script or if we're seeing code that's in medias res within a larger script.
  17. This: 1. Assuming $var has a value of 0, which statements evaluate to true? * $var == false - isset($var) - empty($var) - $var === false Is wrong. Isset will evaluate to true since 0 !== null. Empty will evaluate to true since 0 is considered the same as empty. Also, neither -> nor => are pointers. At all. -> is the to member operator. => is essentially an indexer. Pointer has a very specific meaning, one which is never used in PHP itself since we cannot ever touch dynamic memory.
  18. And how would that be useful to a beginner? Really, a question like this does more to prove you know about the details of the language than help a newbie reaffirm they have a grasp of the basics.
  19. Uh....
  20. Agreed. Remember, questions of this caliber are aimed at newbies. Don't ask vague questions, or what you may think are clever trick questions. The whole point is for them to test their knowledge and further their understanding, not engage in trivial pursuit.
  21. The wording could be better. 'Lines' is vague. Do you mean to include comments? Opening/closing PHP tags?
  22. Listen, there's nothing wrong with looking at working code seeing how it works. You should be doing that. However, it's best used as a supplement to learning, and as a springboard to discovering new things you didn't know. The problem is that 3rd party scripts and tutorials will never be as useful as a good book. 3rd party scripts assume a certain level of ability for the people who will be using them, and tutorials tend to gloss over details and jargon due to space limitations. Even worse, a lot of scripts and tutorials are old, and highlight bad ways to do things. O'Reilly books are good. The Larry Ullman book I linked to above is great. Apress books are generally good (although they tend to have some editing problems). That said, you should only buy books whose latest copyright edition is from 2010 or later. Why? PHP 5.3 was released on June 30, 2009, and added a fair amount to the language itself.
  23. While pre-made CMS software can be overkill, and many need to be fiddled with in order to work just so, the most popular options (WordPress, Joomla, Drupal) are free and allow you to modify them, through both plugins and direct code modification.
  24. Please don't bump a topic that hasn't seen any activity in 10 months.
  25. Here's an updated version of the book I started with. It has pictures and everything: http://www.amazon.com/PHP-MySQL-Dynamic-Web-Sites/dp/0321784073/ref=sr_1_1?s=books&ie=UTF8&qid=1347881081&sr=1-1&keywords=larry+ullman
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.