Tagged: PHP Toggle Comment Threads | Keyboard Shortcuts

  • Peter Mahoney 11:43 am on February 9, 2016
    Tags: , code snippets, PHP   

    Quick dirty PHP redirect 

    For when you need to do it and just do it quickly.

    <?php header('Location:http://www.yoursite.com/new_page.html'); ?>
    Permalink | Reply
  • Peter Mahoney 12:23 pm on March 1, 2013
    Tags: directory, display, folder, glob(), , PHP   

    Show all images in a directory using PHP 

    This is a sweet script. It displays all the files in a particular directory. In this case it’s a folder full of user uploads, so it makes keeping an eye on things a breeze.

     foreach(glob('upl/*.*') as $file){
         echo '<img src="'.$file.'" border="0" alt="'.$file.'">';

    You can of course easily modify it to show only JPGs or other image types (if you’re pulling content from a directory of mixed file types) or to edit the echo so it returns images that link to user profiles etc.

    But this is it’s most basic form.

    Permalink | Reply
  • Peter Mahoney 3:00 pm on February 13, 2013
    Tags: #fridayfreebie, , files, , header, html5, , PHP, template, top.php, website template   

    Website code template 

    This is for my fellow developers out there.

    I have a small series of files I copy and paste whenever I’m about to start a new project, they have default templates for various files I use a lot. Like a header, footer, index page, blank stylesheet, and something called “top.php” that I use to open sessions and connect to databases.

    There are also some of my standard folders pre-made too (with the correct server permissions) like “img” (images) and “upl” (uploads).

    This was going to be last week’s #fridayfreebie, but here it is on a Wednesday instead.

    This particular version is the one I use most commonly, and it’s set up for:

    • PHP
    • MySQL
    • HTML5
    • CSS (any version!)
    • and ideally a unix/linux based server, because it references the top level of the site as being “/”.

    I’ve zipped it up to share! Feel free to do whatever you want with it—although there is a lot of Peter Mahoney specific stuff in there, so you might want to take that out. Unless of course you like giving me credit for your work. 🙂

    HTML5 website template (.zip)

    Permalink | Reply
  • Peter Mahoney 3:44 pm on August 31, 2012
    Tags: documentation, , PHP, ,   

    Create custom RSS feeds in WordPress 

    I couldn’t quite work out how best to do create a custom RSS feed in WordPress.

    My task seemed simple enough, to make an RSS feed of news articles from popular news sources…but the RSS feed needed to link back to the original source, NOT the article in WordPress.

    Writing the PHP script to generate the RSS was simple, but the final step was getting WordPress to serve that feed.

    Here’s the documentation I used, in addition to a custom field:

    Create custom RSS feeds in WordPress | Tips4PHP.

    Permalink | Reply
compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help
shift + esc