PHP

php

Number Pair Additions In PHP

Sunday, April 17, 2011 - 00:33

I was helping my son out with his maths homework today and we came across a question that asked him to find some combinations of two numbers that added up to a given number (he is only 6 so this was good maths practice). This got me to thinking about how to calculate all possible ways in which two numbers could be added together to make another number.

Category: 

Automatically Copying The Node Title To The Menu Title In Drupal 6

Wednesday, April 13, 2011 - 17:48

One new feature of Drupal 7 is that any title you give a node will be copied to the menu title field when you create a menu item. I wanted to replicate this functionality in Drupal 6 and so I created a function that did just that. I have used this function a few times in different projects so I'm posting it here.

Category: 

PHP Question: Scope Resolution

Wednesday, April 6, 2011 - 17:09

Question

What is printed after the following code has been run?

1
2
3
4
5
6
7
8
function calc() {
    $a = 1000;
    return $a;
}
 
$a = 1;
calc();
print $a;
Category: