gwt wouter

26
PHP starter •install •variable •function call •array •for-loop •sum •if Wouter van der Ploeg, CMD, 2010

Upload: wouter

Post on 02-Jun-2015

583 views

Category:

Education


1 download

DESCRIPTION

first slides of CMD programming

TRANSCRIPT

Page 1: Gwt wouter

PHP starter

•install•variable•function call•array•for-loop•sum•if

Wouter van der Ploeg, CMD, 2010

Page 2: Gwt wouter

PHP starter

•http://www.php5.org/

•apache: http://httpd.apache.org/download.cgi#apache22•php: http://windows.php.net/download/•configuration:•http://www.thesitewizard.com/php/install-php-5-apache-windows.shtml•important: httpd.conf in /.../apache2.2/conf and php-files in /.../apache2.2/htdocs

•OR•http://www.wampserver.com/en/index.php•php-files in /.../wamp/www

Wouter van der Ploeg, CMD, 2010

Page 3: Gwt wouter

PHP starter

every php program

<?php //start// body?> //end

Wouter van der Ploeg, CMD, 2010

Page 4: Gwt wouter

PHP example 1<html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body> </html>

Output:

Wouter van der Ploeg, CMD, 2010

Page 5: Gwt wouter

PHP example 2<?php echo '<p>Hello World</p>'; ?>

Output:

Wouter van der Ploeg, CMD, 2010

•put text example2 in a file "hello2.php"•put the file "hello2.php" in /../../htdocs•(or if wamp in /.../wamp/www)•address browser = localhost/hello2.php

Page 6: Gwt wouter

PHP example 3<?php phpinfo(); ?>

Output:

Wouter van der Ploeg, CMD, 2010

Page 7: Gwt wouter

PHP starter - function

<?phpphpinfo(); ?>

Wouter van der Ploeg, CMD, 2010

function call

Page 8: Gwt wouter

PHP starter - variable

<?php$number = 2;

$text = 'voorbeeld';echo $text;

echo $number; ?>

Wouter van der Ploeg, CMD, 2010

variable value

show value of $text

Output ?

Page 9: Gwt wouter

PHP starter - variable

<?php$num1 = 3;$num2 = 7;echo $num1+$num2;echo $num1*$num2; ?>

Wouter van der Ploeg, CMD, 2010

Output ?

Page 10: Gwt wouter

PHP starter - variable

<?php$num1 = 3;$num2 = 7;echo 'the sum is: ';echo $num1+$num2;echo '<br />';echo 'the product is: ';echo $num1*$num2; ?>

Wouter van der Ploeg, CMD, 2010

Output ?

Page 11: Gwt wouter

PHP starter - array

<?php$nums = array(1,2,3,4,5,6,7,8); print_r($nums); ?>

Wouter van der Ploeg, CMD, 2010

Output ?

Page 12: Gwt wouter

PHP starter - array

Wouter van der Ploeg, CMD, 2010

Output:Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 )

valueindex

Page 13: Gwt wouter

PHP starter - for-loop

Wouter van der Ploeg, CMD, 2010

Output ?

for-loop

block

for ($tel = 1; $tel <=10; $tel++)

{ echo $tel*$tel, ' ';

}

start end count

Page 14: Gwt wouter

PHP starter - for-loop - sum

Wouter van der Ploeg, CMD, 2010

Output ?

$sum =0;

for ($tel = 1; $tel <=10; $tel++) { $sum = $sum + $tel; } echo 'total sum =',$sum;

Page 15: Gwt wouter

PHP starter - for-loop & array

Wouter van der Ploeg, CMD, 2010

Output ?

$nameArray = array('jan', 'kees', 'pieter', 'klaas', 'gerben');

for ($tel = 0; $tel <=4; $tel++){ echo $nameArray[$tel];

}

Page 16: Gwt wouter

PHP starter - if

Wouter van der Ploeg, CMD, 2010Output ?

<?php$number = 4;if ($number > 3) { echo $number, 'is larger then 3'; } ?>

Page 17: Gwt wouter

PHP starter - if

Wouter van der Ploeg, CMD, 2010Output ?

<?php$number = 4;if ($number > 3) { echo $number, 'is larger then 3'; } elseif ($number < 3) { echo $number, ' is smaller then 3'; } else { echo $number, ' is equal to 3'; }

?>

Page 18: Gwt wouter

PHP starter - for-loop - if

Wouter van der Ploeg, CMD, 2010

Output ?

for ($tel = 1; $tel <=10; $tel++)

{ if ($tel % 2 == 0) { echo $tel*$tel, ' '; }

}

Page 19: Gwt wouter

PHP starter - for-loop - if

Wouter van der Ploeg, CMD, 2010Output ?

function even($num) { if ($num % 2 == 0) return true; else return false; }

for ($tel = 1; $tel <=10; $tel++){ if (even($tel)) { echo $tel*$tel, ' '; }

}

Page 20: Gwt wouter

PHP starter - if

Wouter van der Ploeg, CMD, 2010Output ?

$nameArray = array('jan', 'kees', 'pieter', 'klaas', 'gerben');

for ($tel = 0; $tel <=4; $tel++){ $naam = $nameArray[$tel]; if (substr($naam, 0, 1) == 'k') { echo $nameArray[$tel]; };

}

Page 21: Gwt wouter

PHP starter - assignments

Wouter van der Ploeg, CMD, 2010

$nameArray = array('jan', 'kees', 'pieter', 'klaas', 'gerben');

1.write 3rd-powers of numbers from 1-992.show squares of even numbers (1-99)3.show name if name is shorter then 5 char's4.give list of names and their length. (look for function length of string)5.give all the names in capitals6.count names shorter then 5 char's

Page 22: Gwt wouter

GWTGoogle Web Toolkit

how to program for all browsers

Wouter van der Ploeg, CMD, 2010

Page 23: Gwt wouter

• GWT

JDK (java)

Apache

Ant

GWT

SDK

Wouter van der Ploeg, CMD, 2010

Page 24: Gwt wouter

• Pyjamas

(port

of

GWT)

Python (>=2.4)

pyjamas

Wouter van der Ploeg, CMD, 2010

Page 25: Gwt wouter

• RubyJS

(port

of

GWT)

Ruby

rubyjs

Wouter van der Ploeg, CMD, 2010

Page 26: Gwt wouter

GWTinstallation

Wouter van der Ploeg, CMD, 2010

•http://code.google.com/webtoolkit/gettingstarted.html•download & unpack gwt-2.0.3.zip (SDK)•download & install (if needed) JDK >= 1.5 •download & unpack Ant 1.8.1

• http://ant.apache.org/bindownload.cgi•Add the bin directory to your path (e.g. add to path ;D:\GWT\apache-ant-1.8.1\bin )•Set the ANT_HOME environment variable (e.g. ANT_HOME = D:\GWT\apache-ant-1.8.1 )•try in shell D:\ ant•if the answer is: Buildfile: build.xml does not exist!•Build failed•All is OK, ant is installed

•test GWT go to•http://code.google.com/intl/nl-NL/webtoolkit/gettingstarted.html