php

How can I include Wordpress posts in a custom PHP file?

This is what i want to do: I want /summary.php to include 5 latest posts (only the extract) from my blog, which lives in /wp. Is there any way to include Wordpress in /summary.php and only print the html for these posts? (Maybe i should parse the rss?) ...

� in my html after purify

I have a database the I am rebuilding the table structure was crap so I'm porting some of the data from one table to another. This data appears to have been copy-pasted from MSO product so as I'm getting the data I clean it up with htmlpurifier and some str_replace in php. Here is the clean function: function clean_html($html) { ...

How to use TDD in a not very "Testy" environment

I work in a company where OOP is... well, not fobidden, but at least frowned upon as "too complex". My coworkers write lots of 100+ lines functions and they are usually all in a "funcs.inc.php" or "something.inc.php", if they use any functions at all, often they don't since copy-paste is faster. I would love to start using TDD at least ...

What's the best approach to rate limit an expensive operation with PHP & Memcached?

I came up with this: if($prog->memcache) { $r = $prog->memcache->get("ratelimit:{$_SERVER['REMOTE_ADDR']}"); if(!empty($r)) $prog->errorClose('This IP has been flagged for potential abuse.'); } foo(); // the thing we're rate limiting... if($prog->memcache) $prog->memcache->set("ratelimit:{$_SERVER['REMOTE_ADDR']}", 1, 0, ...

How to make the first character of the word uppercase?

Do you know is there any function in PHP to make the first character of the word uppercase? Or must I write it by regular expression? ...

SQL IN statement and ordering the results

I have a comma delimited list of ids that I want to use to retrieve records from the database. I can use the IN statement to get the results but I want the order of the results to be the same order as the original list. EG $list = "3,1,4,2,5"; $query = "SELECT * FROM table WHERE id IN (" . $list . ")"; $result = @mysql_query($query); ...

problems with strtolower function

i have some text in foreign language in my page, but when i make it lowercase, it starts to look like this... $a = "Երկիր Ավելացնել" echo $b = strtolower($a); //returns ����� ��������� i've set <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> could you tell me why? thanks in advance ...

PHP 2D Array output all combinations

Hi there, I've had this problem bending my mind for a while now (head cold doesn't help either!), basically I have a PHP array which looks like this example: $array[0][0] = 'apples'; $array[0][1] = 'pears'; $array[0][2] = 'oranges'; $array[1][0] = 'steve'; $array[1][1] = 'bob'; And I would like to be able to produce from this a tabl...

Which order does getTrace return calls?

Probably a trivial question, but in which order does Exception::getTrace return calls? Most recent first or last? I'd like to know before I implement my error handler. BenTheDesigner ...

Why are pieces of my HTML showing up on the page and breaking it? Is it PHP related?

I've been building a site in PHP, HTML, CSS, and using a healthy dose of jQuery javascript. The site looks absolutely fine on my Mac browsers, but for some reason, when my client uses PC Safari, she's seeing strange bits of my HTML show up on the page. Here are some (small) screenshot examples: Figure 1: This one is just a closing <...

Unexpected tag T_ECHO in inline if

I have something like this in one of my views <li <?php $isCurrent ? echo 'class="current"' : ''?> > <a href="SOME_LINK" class="SOME_CLASS">SOME_TEXT</a> </li> This causes a syntax error, unexpected T_ECHO. Changing echo for print solves the issue, but I would like to understand why I cannot use echo. ...

php require and autoload

I use __autoload to load classes, and I keep getting errors that no class is found but file get's loaded ok. Then if I change something in a file, just something like add a new line and save it, everything works fine and class is then found. But this is a great problem cause there are thousands of files in this project and I don't want ...

Extending Zend View Helper Placeholder

I was reading the manual about basic placeholder usage, and it has this example: class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { // ... protected function _initSidebar() { $this->bootstrap('View'); $view = $this->getResource('View'); $view->placeholder('sidebar') // "pref...

PHP. "?>" on top of page.

Hi! I am creating site with php. On localhost all works well. On my hosting all looks good too, but on top of page i see "?>". In my code these symbols are absent. What is this? ...

wordpress conditional statements

I am using this code in wordpress to display different content when different pages are loaded. I have 5 pages on the site called Home, Bio, Work, Contact and Notes. The Notes page is being used as a blog. Here is the code I am using. <?php if (is_page('contact')) { ?> get in touch with me ...

Whats the equivalent asp.net/c# code for this php code?

<?php $system = $_POST['system']; // The FreshBooks system $name = $_POST['name']; // The name of the event that just happened, e.g.invoice.create $id = $_POST['object_id']; $subject = "[$system] Event: $name"; if ($name=='callback.verify') { $body = " $name just happened on $system Verification token: ".$_POST['verifier']." "; } el...

HTML anchor too pull all Sticky Posts ?

Is there a way to format an tag to send a query, pull all Sticky Posts, and loop through them? Since 'sticky' is not a category, I cant format the link in the normal : http://mysite.com/category/cars I'm thinking is probably going to have to be some kind of url query string sent in as GET. ...

Is PHP's require_once() what I need if I want my site to load if AND ONLY IF the menu loads correctly?

I'm kind of confused. I would put all the HTML for the menu in a .php file and have the engine require it right? ...

Defining a variable in a class and using it in functions

I am trying to learn PHP classes so I can begin coding more OOP projects. To help me learn I am building a class that uses the Rapidshare API. Here's my class: <?php class RS { public $baseUrl = 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub='; function apiCall($params) { echo $baseUrl; } } ?> $params will...

I want to better organize my website files, but I can access the .php files using the folder heirarchy. How can I override that?

For example, to access a page in my search folder, I have to write: mywebsite.tld/search/searchJob.php I don't want users to have to write down folder structure and whatnot. What can I do to change this? OR, is there a better way to organize my files? Because I'm only two pages in and I decided to move some files and got lost in the h...