Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Frameworks: One of Proem (a framework created by our very own thorpe), Symfony2, or Zend. IDE: If you're going all out, PhpStorm. Best PHP IDE around, but not free. Totally worth it, though. Workspace: Not quite sure what you mean. Transfer: Filezilla is fine. Not sure what else to recommend, other than some sort of version control (git, subversion). Do you have a linux machine? If not, and you primarily use Windows, I recommend either dual booting or creating a virtual machine environment. I use VirtualBox for my environment (latest version of Linux Mint). It's not as fast as working directly on the metal, but it does the trick.
  2. Yes. We're not going to design it for you, however. That's beyond the scope of what we do here. What we do is provide help for specific problems that our members have at least made a token effort to address on their own. Do you have a PHP-specific question? Any code for us to see?
  3. Thats a good suggestion, the problem is that some of these parameters are already arrays... Then pass in an object. That's generally how the various HTML helper classes I've seen do things.
  4. As a headstart for server security, look into iptables.
  5. It seems a bit overwrought for something that could simply be created in a loop in a view. Overhead without much utility. That said, I have some other issues with it, too. Why are there both a createTable and buildTable method? From a usability POV, those methods tell anyone using the class the same thing. Build and create are synonyms. All you're doing is making a muddled API. Also, from a usability POV, I don't see why both table data and table formatting options can't be passed into the constructor. You have three methods doing what one should handle. Pass options in as either an array or object, and handle them all in one place. Right now, your methods handle arbitrary things (createTable and buildTable both handle alignment and CSS, while the constructor handles the background). There's no clear design intent with that. Remember DRY - Don't Repeat Yourself. Code repetition is a symptom of bad design. Simplify.
  6. 1. You can't have multiple return statements like the way you have them. Return returns that value from the function and then EXITS the function. Everything else below the initial returns won't be executed. 2. I'm not sure what you're attempting to do when you try to invoke the function. What's with all the double quotes and extra parenthesese? Where's your echo statement? Have you read about functions in the online manual (functions)?
  7. Yup, spaces. Of course, any good IDE will allow you to map x spaces to the tab button, giving you the best of both worlds.
  8. Exactly. Cloud computing is the modern equivalent of client <-> mainframe. The difference is that we can connect wirelessly, which gives us unprecedented mobility, and the cloud/mainframe can grow/shrink according to our needs.
  9. http://symfony.com/doc/current/components/dependency_injection.html Damn it man, I'm trying to point as many people toward my framework as I possibly can without looking like I'm spamming the place Ah, shit.
  10. http://symfony.com/doc/current/components/dependency_injection.html
  11. So it sounds like this is the best way to do things... $_SESSION['loggedIn'] = TRUE; And as long as I don't quote anything, then it is the best way to convey what I mean, right? Debbie Yup. TRUE can't be anything else other than, well, TRUE. If you're aiming for clarity, it's a good way to go.
  12. I like this idea, but is there a limit, or tradeoff, when it could slow things down? What if the OP's site had 6 pages and each page pulled 12 HTML content elements via PHP variables (or include/require) and each page had 3-5 style sheets attached. Would visitors experience any delay in pulling all that content vs HTML + PHP on the page? The cost is negligible. Application bottlenecks tend to happen with the db, either with poorly designed tables, or poorly designed queries (especially with queries executed in loops). Include/require is essentially cut + paste. They literally paste the content of the particular file, character-by-character, at the spot where they were invoked. Since this all happens in memory, likely all that's going on is an internal pointer moving from file to file. In short, it's nothing to worry about. The benefits of separating presentation from logic far outweighs any performance hit (which would be in the milliseconds). There's two things going on in the code above. Two files. Template (mostly HTML, with just enough PHP to display specific data): <body> <div> <h1> <!--etc etc --> <?php echo $output; ?> </h1> </div> </body> The main script, which then uses the template: $output ="Hello World"; include("output.php") In real life, the template would likely be in a folder with other templates. The main script(s) would then include/require whichever one was needed after doing all the heavy lifting of processing forms, querying the db, etc.
  13. And, the reason why they're equivalent is because PHP (and other languages) treat 0 as FALSE and any non-negative integer as TRUE. In terms of boolean logic (meaning, binary logic based on true/false), something like: $_SESSION['blah'] = 1; if ($_SESSION['blah']) { // the session value is true echo "true"; } is fundamentally the same as: $_SESSION['blah'] = 2012; if ($_SESSION['blah']) { // the session value is true echo "true"; } Both will echo 'true'. Now, this isn't the case for all languages. C#, for instance, is very strongly typed, so it can't convert from a number to a boolean, and it will throw an error if attempted. The same may be true for Java (not sure).
  14. I wouldn't consider that a problem. Scope is a necessary part of programming, especially OOP, where objects are supposed to have hard boundaries. But, even in a procedural environment, scope and encapsulation allow you to create modular code through functions. The thing to remember is that if your code has an external dependency, like a function that has to use a db connection, you need to pass that dependency to the code that uses it in an explicit way. The way PHP (and other languages) do it is via the argument list. In OOP it's actually a bit easier, as you only need to inject the dependency in once, either right when you need it, or when the object is created. You can store the dependency as an object member, and use it whenever you want. And, since objects are always passed by reference, the dependency object can be passed to others with little overhead.
  15. No, thorpe is saying to never use globals at all, and to pass your db into the functions via their argument lists, like you did in the code above. The same general approach would be used in OOP as well.
  16. You have: $file_name = "prebrief.pdf"; $path = "prebrief.pdf"; $file = $path.$file_name; Which means $file is equal to prebrief.pdfprebrief.pdf. Could be a problem, no?
  17. Why are your $path and $file_name the same?
  18. Indeed, that's what the argument list is for.
  19. I haven't run into a case when I had to use either function. Worse comes to worse, you can always create a small test script to play around with the functions before attempting to use them in 'real' code. That's what I generally do if I want to try something I've never previously attempted.
  20. Uh, he was talking about specific PECL functions which allow one script to dynamically send data via GET or POST to another script, then obtain the results: http://www.php.net/manual/en/function.http-post-data.php http://www.php.net/manual/en/function.http-get.php
  21. EDIT: Never mind, I'm an idiot. Never encountered Phar before.
  22. Mass Effect 3 is incredible, especially if you've played the first two. Unfortunately, it all goes to shit in the last couple of minutes. How bad is the ending? People pissed off at Bioware have raised over $50,000 just since March 13th for Child's Play because they want a better ending: http://retakemasseffect.chipin.com/retake-mass-effect-childs-play That said, the game up to the very, very end, is one of the best I've played this generation.
  23. what realm/faction do you play? Haven't logged in in months (been playing SWTOR... whee $30/month in subscription fees!), but I'm Horde on Shadow Council.
  24. I wouldn't be surprised. That's okay, as I did the 1 year subscription to WoW = free Diablo 3 download. And, I also have Transformers: Fall of Cybertron and Assassin's Creed III on pre-order if it gets delayed significantly.
  25. Yup. Maybe it can wash the taste of Mass Effect 3's ending out of my mouth.
×
×
  • 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.