Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. Your question si not at all clear.
  2. I'm not sure I understand the issue. You have created $facebook within the global namespace so it is available everywhere within that scope. Just include this file where ever you need to.
  3. As the error says, eregi is deprecated. There are details on the manual page about how to handle this.
  4. You should be escaping your data anyway to help prevent sql injections. I'm not sure what db abstraction layer your using but it will likely come with a mechanism for doing so. Even the standard old mysql extension comes with mysql_real_escape_string.
  5. The rule is "no output before a call to the header function. The error tells you where the output is coming from. Line 31 of header.php
  6. Where exactly are you stuck?
  7. I'm not sure you even understood my last reply. I'll leave you to it.
  8. That doesn't sound any different to the example you told us about in Zend_DB and Zend_DB_Excpetion. They are both in the pseudo DB namespace. It's a nice idea to try and decouple your components as best you can but going as fare as removing all hard coded dependencies is not always achievable nor really required. A few exceptions, utilities and other bits and pieces are always going to be excepted as dependencies and no one is really going to be looking to swap these things out or test your components within mocked versions of these things anyway really.
  9. I think your confused about what business logic is. Just because code is written in php does not mean it is business logic. Take this simple template example to list usernames and email addresses. <html> <head> <title>Users</title> </head> <body> <ul> <? foreach ($users as $user): ?> <li><?= $user->name; > - <?= $user->email; ></li> <? endforeach; ?> </ul> </body> </html> While this html has php within it, theres is no business logic here, and it wouldn't really be written any differently using a template engine. For example, in Twig: <html> <head> <title>Users</title> </head> <body> <ul> {% for user in users %} <li>{{ user.name }} - {{ user.email }}</li> {% endfor %} </ul> </body> </html> It might be a little cleaner, but really, that's about it. Of course there is no data escaping in either example and once you start down that path template engines really start to show there benefit, but still even that can be easily accommodated in php alone of you know what your doing. eg; In Twig you would use: <li>{{ user.name|e }} - {{ user.email|e }}</li> while in php you might use something like: <li><?= e($user->name); > - <?= e($user->email); ></li>
  10. The error is pretty self explanatory. You should learn to format better questions if you want better answers.
  11. I don't think you really want to to making separate http requests to get the data you are after. What I actually think your trying to do could easily be solved with functions. For example: function fetchMapData($country, $regions = array()) { // For real, you would generate $data from the database most likely // As an example though, I'm just hard coding it into the function $data = array( 'england' => array( 'south-west' => 'this is south west data', 'north-west' => 'this is north west data' ), 'ireland' => array( 'south-west' => 'this is south west data', 'north-west' => 'this is north west data' ) ); $out = array(); if (count($regions)) { foreach ($regions as $region) { $out = $out[] = $data[$country][$region]; } } else { foreach ($data[$country] as $region => $value) { $out[] = $value; } } return $out; } var_dump(fetchMapData('england')); // return all regions within england var_dump(fetchMapData('england', array('north-west'))); // return just north west region var_dump(fetchMapData('england', array('south-west', 'north-west'))); // return south west & north west region This hides all your logic within one place, the fetchMapData() function and makes it very easy to retrieve in multiple different pages without duplicating the code everywhere. Does this help?
  12. So you plan on hacking the Zend_Db class so that it no longer has this dependency hard coded? That still doesn't sound like a decent solution.
  13. It's not something that is simply "fixable". This is how the entire site looks to be programmed. It looks like it's using the jQuery mobile framework which basically creates a single page web application. The stuff in the url is some form of id that the site needs so as to know what data you are requesting. It's a basic client side mvc. To "fix" this issue would mean redeveloping the entire site.
  14. That is indeed correct. However there is no point passing any old object into a class if that class doesn't know what to do with it. Hence, most people use type hinting along with dependency injection so as to ensure there is some form of contract between the two classes. That was what I was trying to get at. Why are you using Zf1's error classes within your own router?
  15. I'm not saying you need to learn some other framework from the ground up. I'm saying these frameworks are much better designed and are much less tightly coupled. For instance, you should be able to install whatever database stuff Zf2 now provides (I don't use Zf1 or Zf2) via composer and this will install everything it needs to work. It's actually pretty hard to see from your example what your stuck on. I meen, it looks like "your" router class, surely it should know what type of exception it is going to be throwing? I meen, any calling code is going to need to know what exception is being thrown too, how do you propose that is handled? Anyway, if you don't want to be injecting actual objects, you could go down the path of IoC containers and all that jazz. Iv'e built them before and a simple implementation is just that, simple, it's only as you start adding more functionality that they become more complex.
  16. You know they are two completely different technologies that do two completely different things right?
  17. I would suggest that the whole issue revolves around the fact that your using ZF1 components which are out of date and (as you can see) are not very easily used as stand alone "components". Why don't you use ZF2 stuff? or Symfony2 stuff, or Laravel stuff or any other modern framework that uses namespaces, PSR-0 and composer ? This, would solve a number of your issues out of the box. Injecting a string and relying on that being a valid class name for a class that may or may not exist just seems very unreliable. If your going to "inject" something, it should be an object that implements some interface. You then rely on the interface, not the implementation.
  18. Again, this can be achieved without a templating engine.
  19. It's pretty unclear as to what your trying to do. If you only want the "Hello World" to appear in the form after it's been submitted, it kinda makes your form redundant. <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $result = "Hello world!"; } else { $result = ''; } ?> <form method="post" action="script.php"> <input type="text" value="<?= $result; ?>" readOnly> <input type="submit"> </form>
  20. Is there a particular reason your reinventing this wheel? If you really want to use a templating engine there are some awesome engines around these days. Twig is very feature full yet light weight. I personally don't see the point in templating engines, separation of presentation logic from the business logic is more in your app design. Templating engines do little to resolve this issue besides adding another layer between the two.
  21. Unless you want to make a request to the server yes. PHP is executed server side, long before the html appears in a users browser.
  22. I'm not exactly sure how the internals of gethostbyaddr() work but I would assume it's a simple DNS lookup of some sort. Maybe your server is switching between different DNS servers to do it's lookups? These servers may indeed have different hostnames registered.
  23. That would require Javascript not 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.