Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You can't trust any input and milesap's supposed solution doesn't work either (what prevents them from reading out the source of your form reading the value of the token placing it into their form and submitting it?). Nor does litebearer's solution, how do you determine the source with only a token on the server? VALIDATE ANY AND ALL INPUT and reject it even if it's just a bit off.
  2. This problem does not hold only to functional programming but also to OO some solve this problem like: $var = $obj->foo('red', 'horse') ->setState('texas'); getFoo() returns an object that can be configured function setState($state) { //do bla en blabla return $this; }
  3. Wrong. Explanation: reference #1 If we look closely at this page we see that the operators + - . have a left associativity which means it's executed from left-to-right. In the expression 'h' . 1 + 2 . is executed first becoming 'h1' + 2. reference #2 If we look at this page we see that an operation as [string + integer] integer is preferred and the string is converted to an integer (0) translating the statement 'h1' + 2 to 0 + 2. Correct. Correct. Correct. ------------------ Riddle me this, riddle me that: echo '1h' . 2 + 3 There's a little subtly in this one
  4. Use array_filter to remove empty values. implode(',', array_filter($currentIds))
  5. That isn't re-using, not as I see it. I don't have to strip out some code in the Zend framework to use it in a new project do I? Re-think your design quite possibly your missing something to truly make your class re-usable. All projects are under version-control and have a svn:externals defined for both Zend framework and our own framework that has grown over the years. When we get a new project we create a domain design often this design leads to new components (eg Services) that are not domain-related and thus suitable for the Infrastructure layer (frameworks, libraries, and the like). It sometimes happens that we adopt domain classes (eg Models) to new projects but these - like the project - evolve over time. We never re-use classes from the Application layer (eg Controllers) as the number of lines in those classes are negligible or too application-specific to be re-usable.
  6. Ah.. I guess you missed http://codeigniter.com/user_guide/general/controllers.html#subfolders which allows you to have URL's like http://localhost/admin/ http://localhost/something/ http://localhost/ -- default
  7. Not really. In PHP you can create public properties on-the-fly by assigning a value to them. That's a feature I always hated. I like my objects to have concrete interfaces. Nothing the below can't fix function __set($property, $value) { throw new Exception("Property $property does not exist."); }
  8. I do not think you would get developers doing this. This is purely design work. You'd be surprised how many designers I've run into that refuse to code a .psd into a .html. I do think it is the designers job as well, but sometimes you run across a stubborn mule. Or I've seen job ads where a company asked for a graduate MS to transform PSD's into HTML/CSS/JS. Like in the case of KingPhilip we have junior developers bridging the gap between medior/senior developers and the designers (who I think should not care about more then know how to handle Photoshop and the like as they'll just use Photoshop's abilities to slice and transform to HTML/CSS if you ask them too).
  9. PHP is case-insensitive when it comes to classes, methods, and functions. Also constants if you pass TRUE as a third parameter to define().
  10. Riddle me this, riddle me that, can you solve this off the top of your hat? echo 'h' . 1 + 2; // Output: ? echo true ? 'hello' : 'world' ? 'foo' : 'bar'; // Output: ? echo 'a' < 'A'; // Output: ? echo false == array(); // Output: ?
  11. $id = (int)$_GET['id']; Is the right way. Type-casting will convert anything that it can't type-cast properly to 0 and as an auto_increment primary key won't be 0 you know that whenever it's 0 then it was invalid. For more information on type-casting and how PHP handles all this stuff: http://php.net/manual/en/language.types.php
  12. $cart = $item - $id; should be: $cart = $newcart;
  13. None. Unless they are browsing with a geo-enabled device like an iPhone and allow you access to their location.
  14. Something for you? Chances are you'll blow them away with such an amount of knowledge.
  15. You don't need a degree. Become a web professional. Blog. Teach the masses (and get invited to speak at conferences).
  16. IP-based geo-location is only a best estimate and for some (read dynamic ip-address) will be completely inaccurate.
  17. It isn't. But for a start-up things shouldn't give you a problem anytime soon after all it took until most Twitter users complained from lagg that they finally made the switch to a NoSQL alternative.
  18. I may have forgotten to tell you that you should restart Apache after this process to make the effects visible. Which is actually easy as you only need to click on the wamp tray-icon and press restart all services (for convenience or Apache - Service - Restart Service)
  19. INSERT INTO ShippingProfile (ShippingProfileID, ProductID)VALUES ($shippingProfileID, $productID)ON DUPLICATE KEY UPDATE ProductId = CONCAT_WS('|', ProductId, $productID)
  20. Installing PEAR has it's side-effects on Windows. The include_path is wrong, change it to: .;C:\Wamp\bin\php\php5.3.0\PEAR In your php.ini. If you have a default installation of WAMP find php.ini in your bin\apache\apache2.2.11\bin\ open it and search for include_path. The end result should look like: ; UNIX: "/path1:/path2";include_path = ".:/php/includes";; Windows: "\path1;\path2";include_path = ".;c:\php\includes";; PHP's default setting for include_path is ".;/path/to/php/pear"; http://php.net/include-pathinclude_path = ".;C:\Wamp\bin\php\php5.3.0\PEAR" Chances are there isn't an include_path in this case just write it! Copy this line and paste it also in the php.ini located under bin\php\php5.3.0 this will make this settings effective under CLI.
  21. If you want to direct to a method/action use: $this->url(array('action' => 'add', 'controller' => 'artists'), null, true); If you want to specify an artist and thus use a pre-defined route use: $this->url(array('artistname' => 'The Smiths'), 'artistprofile', true);
  22. Shouldn't be there. You should provide this value when you use the Route like: print $this->url(array('artistname' => 'The Smiths'), 'artistprofile'); Read the errata if you get stuck chances are someone found a problem in the code and reported it.
×
×
  • 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.