php

Making Drupal 6 reverse node order via code in the front page.

I'm trying to get Drupal 6 to reverse the order in which the nodes appear in the frontpage. I'm pretty much using "Story"s as a blog engine and so far it has done it's job pretty well. I'm a bit annoyed though at the fact that nodes are listed in reverse chronological order. I mean, granted, if you want to display multiple node previews ...

Ruby-like array arguments implementation in PHP

I program in PHP mostrly and Ruby sometimes I happen to be in need of a way to implements those "hash arguments" into my PHP funcions (Like, say, an HTML select helper) draw_select :name => :id, :onclick => 'alert(this.value)' The problem in PHP is that I would have to define an argument order to implement many possible attributes. I...

What to define Predefined Constants as.

I have a database class that automatically sets up a connection to the database and does some basic input filtering and whatnot. I am looking at setting some predefined constants to adjust the behavior of the class methods. What should I set the values of the constants as? Since the values will never be referred to, or compared, direc...

Is this PHP class optimized for mysql database access?

I've wrote a quick PHP class to ease the access to a mysql database. The class works ok, and has a query() method that opens up the connection, executes the query and then closes the connection (I know that the connection is supposed to close by PHP itself after the script finishes, but I don't like to rely very much on that). From a pe...

PhpDocumentor installed via PEAR on OSX not working - missing files?

Hi there. I'm basically new to PEAR (and PhpDocumentor); I installed PhpDocumentor using the PEAR CLI, and everything seemed to go fine... until I went to use it, at which point I got the following error: Warning: require(PhpDocumentor/phpDocumentor/phpdoc.inc): failed to open stream: No such file or directory in /usr/local/bin/phpdo...

casting removes leading zeros

Can someone tell me why when I cast a string of say 00332 I only get back 332? It removes the leading zeros and saves the data in the same format. Thanks this->_gate = (string) $this->_linkID->QuoteSmart($gate); ...

What is the best way to get up to speed with PHP/Javascript?

I have built Web sites with Python/Django and desktop applications with Objective-C/Cocoa so programming is not something that I need to learn. For someone in my situation, what is the best way (specific books or Web sites) to learn PHP and Javascript? ...

Looping through a SimpleXML object, or turning the whole thing into an array.

I'm trying to work out how to iterate though a returned SimpleXML object. I'm using a toolkit called Tarzan AWS, which connects to Amazon Web Services (SimpleDB, S3, EC2, etc). I'm specifically using SimpleDB. I can put data into the Amazon SimpleDB service, and I can get it back. I just don't know how to handle the SimpleXML object th...

RAW POST using Curl in PHP

How can I do a RAW POST in PHP using curl. Raw post as in without any encoding, and my data is stored in a string. The data should be formatted like this ... usual HTTP header ... Content-Length: 1039 Content-Type: text/plain 89c5fdataasdhf kajshfd akjshfksa hfdkjsa falkjshfsa ajshd fkjsahfd lkjsahflksahfdlkashfhsadkjfsalhfd ajshdfhsa...

What is the "correct" way to start and close a PHP statement?

Is there any difference or associated risk opening with the following PHP variations? <? echo "hello world!"; ?> <?php echo "hello world!"; ?> <?="hello world!"?> Also, is it necessary to close all scripts with ?> ...

How to know where a form came from?

I was wondering is there a way in PHP that you could tell where a form was submitted without using hidden fields or anything of the like where the user would only need to tamper with the html a little? For example i am trying to work out if a form that was submitted was actually on my website or whether the form was saved offline and sub...

Objective-C Default Argument Value

Hey there, quick question here. I'm sure there's a simple answer. Coming from PHP, I'm used to declaring a function with a default argument value like this: function myFunction ($array, $sort = FALSE) { } I the sort parameter wasn't filled, the function would continue with the default value of false. In Obj-C, is there a similar t...

Introducing Test Driven Development in PHP

My workplace consists of a lot of cowboy coders. Many of them are junior. Which coincidentally contributes to a lot of code quality issues. I'm looking for suggestions on how to best wane my team into using TDD (we can start with Unit tests, and move into regression tests, and later more automated testing). Ultimately, I want us to l...

PHP Pass variable to next page

Hello, it seems pretty simple but I can't find a good way to do it. Say in the first page I create a variable $myVariable = "Some text"; And the form's action for that page is "Page2.php". So in Page2.php, how can I have access to that variable? I know I can do it with sessions but I think it's too much for a simple string, and I do ...

PHP Namespace separator

Someone remind me why "." is not used as the namespace separator? I don't think the "." character is used anywhere else in PHP at all, unless I am mistaken. ...

Why Doesnt PHP Parse My Scripts?

I'm trying to get the php executable to parse scripts, but it's not working. i run something like this: php c:\test.php and test.php contains this: <? echo 'hello!'; ?> and that is exactly what running the command returns. It returns the raw code. How can I get it to actually parse the code and return "hello!" instead? ...

xpath with curl gives empty result?

This code gives me an empty result. I expect it to print out the titles from the XML-file. I need to use Curl to get the file. <?php function get_url($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); $data = curl_exec(...

PHP: Reloading the captcha image from javascript

I have a user registration form in PHP .I put captcha image check in the page.I used it like this <img src="captcha.php" alt="Enter this text in the adjacent text box" id="imgCaptcha" /> and in my javascript i will validate this with the same number which is generated in the image (from captcha.php page) . That number was set in a se...

First time building paypal ecommerce website - how to do it right?

Hi guys, this may come as pretty odd but I'm now working on a membership based website where users sign up and choose mode of membership which would be on monthly, quarterly or yearly payment basis. Its going to be paypal based. However despite having worked 5 years I haven't ever working on any ecommerce project before :\ instead I've w...

Wrap all <img>'s in <div>, take the alt attribute and add it into a <p> inside

Trying to replace this jquery code with some php server side magic: $(document).ready(function() { $('#text img').each(function(){ source = $(this).attr('src'); $(this).wrap($('<div class="caption '+ $(this).attr('class') + '"></div>')).removeAttr('class').removeAttr('height').removeAttr('width'); $(this).after('<p>'...