Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by ignace

  1. Doctrine comes in 3 packages. You only need the DBAL package. Since you already use Composer, installing doctrine is easy: $ php composer.phar require doctrine/dbalSetting up is as easy as: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html
  2. I don't understand why everyone seeking help always ends up giving canned examples. A canned example is a canned answer. Tells us what you are doing, and why you want to do it this way.
  3. OOP is more then simply introducing one class into your project. Or a few classes for that matter. So if you want to use a class for it or go with a function, the choice is ultimately yours. You can avoid having to create the handle over and over by passing the handle to the functions that require them: function login($ch, $other, $parameters) { // code }Personally I would prefer a class to signify the cohesion between the functions and not having to pass the same data around between functions, in a class they would simply share the information. But don't take my word for it though, because I am biased.
  4. Even if you would be able to see how an expert builds a website. You would probably learn nothing, and/or consider yourself really dumb because you don't understand half of what he wrote. The same way you wouldn't learn chinese if you see someone write it. What you need is the mindset of an expert and that is to understand how he solves problems. A project usually has 2 categories. 1) The part you know how to do or can easily google to find out how to do them; 2) The part you have no clue whatsoever how to do; Number 2 is the interesting part. And before anything else you should take into account their importance to the project. So if you have no clue how to do something but the importance of it is optional then you won't invest any time in it at all. And the problem is solved. If however it's critical to the project then it's your primary focus, and solving this before anything else is paramount to the success of the project. Avoiding the complex parts of an application until the end usually means project failure. Furthermore the expert identifies the different components of the project on a high-level, which is the same as categorizing cohesive (=related) portions of the project. For a blog you could identify: Authorization (Access Control) Authentication Blog Post Authoring & Publishing Among others, from this high-level view of your project, you would drill down further categorizing. The advantage here is that it's easier to focus, as the scope is smaller, and after the project has been going for a while you will have a neat whiteboard as a top-down view with all these components and the links between them making it easier to see the big picture and add/factor-in new functionality. And I think that after you reading this I have proved my first point.
  5. objnoob is on to the right idea. function setSettingsForBrand($brand) { switch ($brand) { case 'intel': setIntelSettings(); break; default: setDefaultSettings(); break; } }So in the case of where you have a brand with no corresponding function, or misspelled the brand name, your application wouldn't error out but instead simply apply the default. Magic is cool, but not in your code. Because in the end it will pull it's greatest trick on you.
  6. Yes, but if you want to specify the third parameter, you'll also have to specify the second one.
  7. Simply use intval $string = "<214.27080, 204.10100, 2500.51300>"; //Convert string into array - splitting on the commas $parts = explode(',', $string); //Iterate over each value in the array foreach($parts as &$part) { //Trim spaces and "<>" from each value and return the rounded down value $part = intval(trim($part, " <>")); } //Convert the parts of the array to a string using '/' as delimiter $newstring = implode('/', $parts);
  8. That's because you need to specify the third parameter. mkdir mkdir($dir, 0777, true);
  9. When you include composer in your project, it automatically loads all files and functions for you. No need to write your own variation.
  10. Turn on error_reporting, your hosting does not support curl. error_reporting(-1); ini_set('display_errors', 1);At the top of your script.
  11. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://api.worldoftanks.eu/2.0/account/info/?application_id=d0a293dc77667c9328783d489c8cef73&account_id=509662813"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); $json = json_decode($output); echo $json->data->{'509662813'}->statistics->all->battles;Prints: 2579 Try it here: http://phpcodepad.com/
  12. echo $json->data->{'509662813'}->statistics->all->battles;
  13. Every class should have a single responsibility, forcing the responsibilities of Order onto Input means it is doing work it shouldn't have to. It also makes it harder for future developers working on your project to continue development due to classes having responsibilities that they are not aware of. Which is why it's best to make your model as explicit as possible. And Order is a better name (since the customer orders a product by placing it into his basket) then Input. Just like you would have a Product class instead of naming it Input as well. Input is better suited for all incoming request data. So that you can do: $input->get('product_id'); $input->post('product_id'); // etcNot to represent an Order or Product.
  14. You would learn the changes since you left at the same place you frequented as an advanced PHP developer: php.net: migrating from 5.2 to 5.3 Just follow this all the way up to 5.5 and you'll be up-to-speed in no time.
  15. What is it exactly that you expect here? That we simply develop the website for you, and you get the money? Are you really that naive or simply that stupid?
  16. They take the .torrent files and download them from their servers, in a queue table, search for PHP torrent download. The place where they store the downloaded files is shown to the user along with the status of the download.
  17. When you have something like this, a bunch of classes and some functionality, and you don't know where to put it, you need to analyse your model and try to find missing components. In your case, you are missing Order. Your Customer Orders a Product by placing it into his Cart. $order = new Order($someProduct, 12); $cart->add($order);
  18. If you can run your code locally, you can use these tools to analyze your code: http://phpqatools.org/ Install xdebug and enable profiling, go through your application and it'll show you how long each call took and how often they are called. You need WebGrind or something similar to view the profiler output. Perhaps you have a function that is called many times, simply caching it's results will speed up your website. function simple_cache_example($foo) { static $cache = array(); if (isset($cache[$foo])) { return $cache[$foo]; // already calculated } // do calculation $cache[$foo] = $calculated; }Enable the query log and set it to table. Go over your application and view the executed queries in mysql.general_log, perhaps you'll see that one query is executed several times though it's result does not change: SELECT .. FROM some_table WHERE something = 'this'; .. SELECT .. FROM some_table WHERE something = 'this'; .. SELECT .. FROM some_table WHERE something = 'this'; .. SELECT .. FROM some_table WHERE something = 'this';Cache the result from the query as shown in the above function. Same for simple variations: SELECT .. FROM some_table WHERE something = 'this'; .. SELECT .. FROM some_table WHERE something = 'that'; .. SELECT .. FROM some_table WHERE something = 'there'; .. SELECT .. FROM some_table WHERE something = 'maybe';Simply combine it and return the correct result on each consecutive call: SELECT .. FROM some_table WHERE something IN('this', 'that', 'there', 'maybe'); .. if ($cache[$what]) { .. }You may not have these tools available due to the shared hosting. APC: Caches the PHP opcode, so your scripts no longer have to be 'compiled' between requests. It can also be used to cache your own data, like large result sets. apc_store apc_fetch Varnish: Caches your website pages and thus reduces hits to your database. For pages with partial dynamic content you can use edge side includes which are fetched by varnish and placed ad-hoc. https://www.varnish-cache.org/trac/wiki/ESIfeatures This is simply scratching the surface of the things you can do to speed up your application/website.
  19. LOL. You don't reject a browser simply because it doesn't properly renders your website. These are not the dark ages of webdevelopment where it was common to give a preference for a specific browser and version. Your website should display properly in IE8+, Chrome, Firefox, Safari, etc.. If it doesn't you need to change your CSS.
  20. Well perhaps you should put in some effort and actually do what SocialCloud told you to do. What he said is correct, but you have failed to apply it. You can not use session_start() after sending output to the browser. All the HTML above <?php is output. Turn on error_reporting with: error_reporting(-1); ini_set('display_errors', 1);And write your PHP first, your HTML second as in: <?php session_start(); error_reporting(-1); ini_set('display_errors', 1); // PHP code here ?> HTML code here (yes that is <!DOCTYPE ..><html> and everything)Do not use session_is_registered() or session_register() but instead use the global variable $_SESSION. Stop following the tutorial you are reading, it's outdated. To check if a session variable has been registered: if (isset($_SESSION['is-this-here'])) { // yes it is } // to create session variables $_SESSION['i-am-persisted'] = true;
  21. I think the design is outdated. Look at the website of the company I work for: http://www.statik.be It's minimalistic yet very modern. And shows-off some recent technologies to make the page more dynamic while impressing our clients.
  22. Simply removing them is not sufficient. You need to change your FTP credentials and try to track down how they were placed on your server and fix it.
  23. You'd do best to remove these files asap. They are used to mail (spam) from your server and it allows them to send arbitrary cmd's to your server. In the order of # rm -rf /
  • 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.