Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. Yes, use gethostbyaddr
  2. Your code gives serious doubts whether you actually understand OOP. The four basic ideas behind OOP are: Inheritance, Polymorphism, Abstraction, and Encapsulation. Your classes are anything but encapsulated. And globals, seriously? Stop reading tutorials and start reading books! You are using one class to modify another (newTemplate::setTemplate())? Don't you think that functionality should then be in the class that it manipulates? Look at the below example: interface Template { public function assign($var, $value); public function render($script); } class SmartyTemplate implements Template { public function assign($var, $value) { /**/ } public function render($script) { /**/ } } class ASF { private $_template = null; public function setTemplate(Template $template) { $this->_template = $template; } } I have created an interface Template so that I am not bound to any particular rendering engine (PHP, Smarty, PHPTAL, ..): $asf->setTemplate(new SmartyTemplate()); $asf->setTemplate(new PhpTalTemplate()); That's called Abstraction and using Polymorphism I can pass any class implementing Template. The variables in ASF are encapsulated, you can only modify them through setTemplate() and on ASF terms which was not the case in your example where anyone could pass anything to _template. This would work for example in your code: $asf->_template = "booboo!"; Which is not the desired functionality.
  3. Post the class in it's entirety then we can advise you on structure, possible patterns (Strategy maybe?) and such. But with fake code we can only point out syntax error's.
  4. http://www.phparch.com/books/phparchitects-guide-to-web-scraping-with-php/ php|architect's Guide To Web Scraping
  5. ignace

    3 ways

    Try that: SELECT items.*, image.imageid, image.imagename, tickets.item, tickets.paypal, tickets.amount FROM items LEFT JOIN image ON items.imageid = image.imageid LEFT JOIN tickets ON tickets.item = items.id WHERE items.id = $ticketItem
  6. Yes. foreach ($people as $human) $human->die(); Peace, one cycle at a time
  7. And I want a brand new car (preferrable A-class or B), be promoted to CTO, the mortgage on my house to disappear, my startup to become fortune-500, .. euhm.. did I left something out?
  8. LOL, she isn't his daughter LOL and if she was she certainly wouldn't be 8 but 12 or 13 by now.
  9. @mikesta that's exactly what I meant. I mistyped.
  10. Why not put cron.php under your webroot?
  11. The way I see it he should just pass the ASP.NET array to the method the SOAP class will automatically transform it into a format the PHP script will understand.
  12. You say you have no control over the PHP the code yet you come up with an example like this: $c = recordUpdate('public','',array('firstname'=>'John', 'lastname'=>'Doe')); What do you not control? The code of recordUpdate()? What prohibits you from writing: $c = recordUpdate('public','',$_GET['myarray']); Or are you calling this using SOAP? RPC? Help me help you, give me the information I need, don't let me drag it out of you I have no magic ball I can look into.
  13. Do you have control over the PHP code? If the PHP script is a webservice what does the docs say? service.php?myarray[]=hello&myarray[]=world&myarray[]=foo&myarray[]=bar&myarray[]=baz print_r($_GET['myarray']);
  14. Why cast a string to a float while you can just write the float? var myvariable = .27;
  15. You can tell PHP to return any format ASP.NET understands. If ASP.NET understands JSON encoded strings then you can communicate with ASP.NET using JSON-encoded messages or XML or CSV or .. I don't see how the internal structure of an array is important since you are treating it as a webservice.
  16. Using pull technique is a bad idea but I see no harm for smallish websites. JS also support push techniques: APE. Their is also Node.js among others. Your script should account for these different techniques and allow the end-user to select the appropriate technique. More information: HTTP Streaming
  17. bcsub($a,$b); The correct result of 350000 / 360000000 = 0.0009722222222.. not 0.0009214444.. The reason to why you get an incorrect output is due to the precision loss of a float. Using the BCMath module of PHP you get: echo bcdiv(350000, 360000000, 10); // 0.0009722222 10 is the level of precision you need.
  18. What's the code in renderQuiz()? Did you try adding a simple <br> in your code to separate the questions from the answers?
  19. set_time_limit: set_time_limit(0); makes your script run indefinitely
  20. Maybe? RewriteEngine On RewriteCond %{HTTP_HOST} ="site.com" RewriteRule (.*) http://www.site.com/$1 [R=301,L]
  21. No. The PHP example is for if you use the FrontController concept.
  22. Or if ($_SERVER['HTTP_HOST'] == 'site.com') { header('Location: http://www.site.com' . $_SERVER['REQUEST_URI'], 301); exit(0); }
  23. RewriteEngine On RewriteCond %{HTTP_HOST} ="site.com" RewriteRule (.*) http://www.site.com$1 [R=301,L]
  24. Data validation is done in the model not checking whether the form was submitted.
  25. I asked you if the file was named hello.php.txt !!!!!!!!! http://windows.microsoft.com/en-US/windows-vista/Show-or-hide-file-name-extensions and then change the name to hello.php
×
×
  • 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.