Jump to content

simshaun

Members
  • Posts

    200
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

simshaun's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. And does your original code take into account somebody leaving tags unclosed? Sometimes its not best to re-invent the wheel.
  2. You'd need to use preg_replace_callback. Also, why not use an existing BB code parser?
  3. I think it would be better to implement query caching. Every 12 hours, run the query and store its output in a single row of a "cache" table.
  4. function is_palindrome($str) { return $str == strrev($str); }
  5. strtotime does take into account the timezone modifier. I do see a problem though.. you lose track of the offset when storing the date into MySQL. When you go to re-create a feed, you'll have no idea what the timezone offset was. I suggest storing the entire pubDate value in a varchar column and storing a UNIX timestamp representation of it in an INT column. You could then sort by the int column but still have the original RFC822 format for generating a feed.
  6. It is a little old, but I don't see why it wouldn't work. (You could update it yourself ya know..) http://www.c-worker.ch/txtdbapi/index_eng.php Also, how much is this going to be utilized? If your answer is "a lot", I highly suggest you go to MySQL. Flat-files are easy to corrupt.
  7. So you want 3 years from the current year? echo date('Y-m-d', strtotime('March 1 + 3 years'));
  8. I don't think you can wrap PHP's default error handler without replicating it in your own code. I think the closest you can come is to use set_error_handler to define your own error handling function. Have your custom error handler unset the session vars, call restore_error_handler(), then call trigger_error() using error_get_last() to generate the error string. Edit: Is there a reason you want to use PHP's default error handler? If its just to save you the hassle of coding, check out the docs on set_error_handler. There are some decent implementations in the user comments.
  9. Yes, that will convert the quotes (and more) to html entities, so you don't have to worry about quote usage. But, do you plan on injecting the strings directly into a link like that when you implement what you're trying to do? If so, you're fine. If not, you may want to reconsider using htmlspecialchars. It really just depends on what you plan on doing in the application.
  10. Echo'ing directly into an HTML attribute requires a little bit more treatment, because you have to worry about not using the same style of quotes you used to surround the HTML attribute value. As an example: <a href='javascript:void(alert(<?php echo str_replace("'", '"', json_encode('Foo')); ?>));'>json test</a> What I would do instead, to avoid worrying about the type of quotes: <script type="text/javascript"> var foo = <?php echo json_encode('foobar'); ?>; </script> <a href="javascript:void(alert(foo));">json test</a>
  11. If you are trying to pass the entire array at once, you need to json_encode it. If you are trying to pass a single string, you need to escape whatever style quotes surrounds the string in javascript, e.g. <script type="text/javascript"> var foo = '<?php echo "Lorem Ipsum Wasn\'t!"; ?>' </script> Edit: I forgot to mention, the easiest way of doing this is to just json_encode the string. e.g. <script type="text/javascript"> var foo = <?php echo json_encode("Lorem Ipsum Wasn't!"); ?> </script>
  12. $name = $valueFromXml; if (strpos($name, '#') !== FALSE) { $name = substr($name, 0, strpos($name, '#') ); }
  13. It may be overkill for what you want, but check out phpseclib.
  14. Have you tried C:\inetpub\wwwroot\php\webphp.xml? If so, did you escape the backslashes (assuming you surrounded the string with double-quotes?) Alternatively, ../webphp.xml
  15. I don't think it possible without refreshing the page (which you probably don't want). Once data is sent to the browser from the script, its up to the browser to do something with it (meaning its out of PHP's hands). I've got an idea, but I don't think its very efficient and may not work as intended due to several factors affecting 'flush()'. Have your script echo '<div>content here</div>' and flush() it to the browser, and setup an interval in js to remove "old" div elements from a container.
×
×
  • 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.