Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. I never get results in another language, unless I am searching for something really obscure and only get 2-3 results.
  2. I prefer to just use something like jQuery for AJAX. It is more flexible and I have way more control without having to modify anything. Plus, if you are using MVC, your Views are already separate from everything else.
  3. Again, what part of PHP's OOP syntax did it take from Java? Java didn't invent OOP. Java took its ideas from something else as well.
  4. I use OmniBar for that.
  5. Yeah, I was able to finish the test but then nothing happened. :/
  6. This topic has been moved to CSS Help. http://forums.phpfreaks.com/index.php?topic=364858.0
  7. I can watch this show over and over and over and still fall out of my seat laughing. Sounds like you should get a sturdier chair!
  8. Doctor Who Red Dwarf Hyperdrive Green Wing You forgot Top Gear! The US Top Gear is shitty.
  9. Oh. I watched season 1 of The Office (US). I didn't think it was that good.
  10. I feel like I'm missing something.
  11. Garbage In, Garbage Out? That's my best Google-fu guess anyway.
  12. Is there a problem with that?
  13. It could be a permissions issue. Does it work on other files? Do the files have different permissions set? if (eregi("\.pdf",$file) || eregi("\.txt",$file) || eregi("\.jpg",$file)){ $dirFiles[] = $file; } This is one of the most ridiculous file-type checks I've ever seen. All you are doing is checking that one of those strings exists anywhere in the filename. So, ANicePicture.jpgJustKiddingImAVirus.exe is perfectly valid and passes your check. Aside from the fact that your regex doesn't work, checking the filename doesn't do any good, because the filename is not indicative of the filetype. You need to be checking the MIME type, with something like fileinfo.
  14. What are you trying to do?
  15. The alternative is to define the base URL somewhere (like a config file) and then building it for your pages with a function. You could build another function that retrieves the URL or specific segments. Here's an example. <?php // define the base url define('BASE_URL', 'http://example.com'); function build_url($params = array()) { $query = !empty($params) ? '?' . http_build_query($params) : ''; return BASE_URL . '/' . $query; } function get_url_segment($index = null) { $segments = array(); if (!empty($_SERVER['QUERY_STRING'])) { parse_str($_SERVER['QUERY_STRING'], $query_string); // loop through the query string // sanitize the key and value foreach($query_string as $key => $val) { // remove illegal characters $key = preg_replace('/[^a-z0-9_]/i', '', $key); // replace illegal characters with _ $val = preg_replace('/[^a-z0-9_\-+]/i', '_', $val); // remove duplicated _ $val = preg_replace('/_{2,}/', '_', $val); // add to the segments array $segments[$key] = $val; } } // no index? return everything if (is_null($index)) { return $segments; } return isset($segments[$index]) ? $segments[$index] : null; } function current_url() { $segments = get_url_segment(); return build_url($segments); } With these functions, you can now do things like: <?php echo '<a href="' . build_url(array('foo' => 'bar', 'bar' => 'foobar')) . '">Link</a>'; // http://example.com/?foo=bar&bar=foobar echo get_url_segment('foo'); // bar echo get_url_segment('bar'); // foobar echo current_url(); // http://example.com/?foo=bar&bar=foobar
  16. No. Java is a compiled desktop/system language with entirely different design goals than PHP. The two are not comparable. PHP is primarily a web language. Even though it can be used from the command line or even for some desktop applications, that is not what it was designed for and it's not very good at that.
  17. That's completely irrelevant, because the webserver needs to be able to access them or nobody can see them.
  18. Eh, I'm a little rusty on my Perl, but you can use my, local, and our modifiers to change scope. I don't think any of these change how a function sees outside variables, but it changes the way packages see outside variables. EDIT: And, those modifiers change how the program sees variables declared in the function. sub a { $foo = 'bar'; // this is global } ... sub a { my $foo = 'bar'; // this is not global }
  19. I think the article you linked gives plenty of information for what you should do.
  20. Huh. So, do they not have function parameters? They do. This is a JavaScript example, which works on the same principle: var foo = 'bar'; function a() { console.log(foo); } a(); // foo ... function a() { var foo = 'bar'; } a(); console.log(foo); // undefined
  21. You also get to use something like Nginx to process the image requests, since it is faster than Apache for static things like that. Or, you could take advantage of something like Amazon S3.
  22. I have mixed feelings about this. Global is one of very many things that you can use wrongly in PHP. Should the language enforce good practices for everything? If not, why is Global so special?
  23. While i don't disagree with you at all, i fear half of the web would explode! Look at the fallout from GoDaddy's hosting services' recent changes. If there are websites out there relying on software source last updated 10 years ago, how can ye hath faith phasing global out would accomplish much at all. muffled laughter
  24. $string = '<strong>Dynamic Title, so will be different on every loop</strong> Rest of text etc'; $newString = preg_replace('/<strong>(.*?)<\/strong>/si', '', $string);
×
×
  • 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.