Wednesday, April 20, 2011

Data Type & Constant

| Wednesday, April 20, 2011 | 0 comments

Data Type 
In PHP, the variable data type is not defined by the programmer, but
automatically determined by the PHP interpreter. However, PHP supports 8
(Eight) pieces of primitive data types, namely:
1. boolean
2. integer
3. float
4. string
5. array
6. object
7. resource
8. NULL




PROBLEMS
1. Creating a static variable value to display and save data majors
lat03.php name.
2. Creating a dynamic variable value to display and save data majors
lat04.php name.

   1:  <? Php 


   2:  $ NIM = "09.12.9999"; 


   3:  $ Name = 'STMIK AMIKOM YOGYAKARTA'; 


   4:  $ Age = 16; 


   5:  $ Value = 82.25; 


   6:  $ Status = TRUE; 


   7:  echo "NIM". $ NIM. "<br>"; 


   8:  echo "Name: $ name <br>"; 


   9:  print "Age:". $ age; 


  10:  print "<br>"; 


  11:  printf ("Value:% .3 f <br>", $ value); 


  12:  if ($ status) 


  13:  echo "Status: Active"; 


  14:  else 


  15:  echo "Status: Not Active"; 


  16:  ?> 








Constant


Constant is a variable whose value is fixed. Constant only rated at


beginning of the program and its value is never changed during the program runs.PHP has


defines some constants, eg: PHP_VERSION, ie constant


provide information about the PHP version being used. In addition to constants that have been


provided by the PHP we also can create their own constants. Writing rules


constants are as follows:


define ("nama_konstanta", "nilai_konstanta")


Examples of the use of constants:


Save with the name "Lat05.php" (Constant static value)





   1:  <html> 


   2:  <head> 


   3:  <title> Using constants </ title> 


   4:  <head> 


   5:  <body> 


   6:  <? Php 


   7:  define ("CAMPUS", "STMIK AMIKOM YOGYAKARTA"); 


   8:  define ("SLOGAN", "COLLEGE PLACE PEOPLE tie"); 


   9:  print "CAMPUS". CAMPUS; 


  10:  echo "<br> SLOGAN:". SLOGAN; 


  11:  ?> 


  12:  </ Body> 


  13:  </ Html> 


 


OPERATOR in PHP

Type Operators Operator Description Example


Arithmetic


+ $ A + $ b Added


- $ A - $ b Reduction


* $ A * $ b Multiplication


/ $ A / $ b Division


% $ A% $ b Modulus, residual distribution


Assignment = $ a = 7; $ a is filled with 4


Bitwise


& $ A & $ b Bitwise AND


| $ A | $ b Bitwise OR


^ $ A ^ $ b Bitwise XOR


~ $ A ~ $ b Bitwise NOT


<<$ A <<$ b Shift Left


>> $ A>> $ b Shift Right


Comparison


== $ A == $ b Same


=== $ A === $ b Identical


! = $ A! = $ B Not Same


<> $ A <> $ b Not Same


! == $ A! == $ B Not identical


<$ A <$ b Less than


> $ A> $ b More than


<= $ A <= $ b Less than equal to


> = $ A> = $ b More than equal to


Logic


and $ a and $ b is TRUE if $ a and $ b TRUE


& & $ A & & $ b is TRUE if $ a and $ b TRUE


or $ a or $ b is TRUE if $ a or $ b is TRUE


| | $ A | | $ b True if $ a and / or $ b is TRUE


xor $ a xor $ b is TRUE if $ a or $ b is TRUE, but


not both


! ! $ A TRUE if $ a is FALSE


String. $ A. $ B Merging strings $ a and $ b


Save with the name operator.php





   1:  <? Php 


   2:  $ Salary = 1000000; 


   3:  $ Tax = 0.1; 


   4:  $ THP = $ salary - ($ salary * $ tax); 


   5:  echo "salary before tax = USD. $ salaries <br>"; 


   6:  echo "The salary taken home = Rp. $ THP"; 


   7:  ?> 





Save with the name operator2.php 






   1:  <? Php 


   2:  $ A = 5; 


   3:  $ B = 4; 


   4:  echo "$ a == $ b:". ($ A == $ b); 


   5:  echo "<br> $ a! = $ b:". ($ A! = $ B); 


   6:  echo "<br> $ a> $ b:". ($ A> $ b); 


   7:  echo "<br> $ a <$ b:". ($ A <$ b); 


   8:  echo "<br> ($ a == $ b) & & ($ a> $ b): ".(($ a! = $ b) & & ($ a> $ b)); 


   9:  echo "<br> ($ a == $ b) | | ($ a> $ b): ".(($ a! = $ b) | | ($ a> $ b)); 


  10:  ?> 


 


 








Technorati Tags: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,





Windows Live Tags: Data,Type,Constant,programmer,interpreter,integer,resource,NULL,OUTPUT,PROBLEMS,majors,Name,STMIK,AMIKOM,YOGYAKARTA,Value,Status,TRUE,Active,size,Consolas,Courier,Monospace,margin,width,constants,PHP_VERSION,information,version,addition,Examples,Save,CAMPUS,SLOGAN,COLLEGE,PLACE,PEOPLE,Body,Html,OPERATOR,Operators,Description,Example,Arithmetic,Reduction,Multiplication,Division,Modulus,distribution,Assignment,Bitwise,Shift,Left,Comparison,Same,Identical,Logic,FALSE,Salary,salaries,csharpcode,ffffff,kwrd,preproc,attr,lnum







WordPress Tags: Data,Type,Constant,programmer,interpreter,integer,resource,NULL,OUTPUT,PROBLEMS,majors,Name,STMIK,AMIKOM,YOGYAKARTA,Value,Status,TRUE,Active,size,Consolas,Courier,Monospace,margin,width,constants,PHP_VERSION,information,version,addition,Examples,Save,CAMPUS,SLOGAN,COLLEGE,PLACE,PEOPLE,Body,Html,OPERATOR,Operators,Description,Example,Arithmetic,Reduction,Multiplication,Division,Modulus,distribution,Assignment,Bitwise,Shift,Left,Comparison,Same,Identical,Logic,FALSE,Salary,salaries,csharpcode,ffffff,kwrd,preproc,attr,lnum







Blogger Labels: Data,Type,Constant,programmer,interpreter,integer,resource,NULL,OUTPUT,PROBLEMS,majors,Name,STMIK,AMIKOM,YOGYAKARTA,Value,Status,TRUE,Active,size,Consolas,Courier,Monospace,margin,width,constants,PHP_VERSION,information,version,addition,Examples,Save,CAMPUS,SLOGAN,COLLEGE,PLACE,PEOPLE,Body,Html,OPERATOR,Operators,Description,Example,Arithmetic,Reduction,Multiplication,Division,Modulus,distribution,Assignment,Bitwise,Shift,Left,Comparison,Same,Identical,Logic,FALSE,Salary,salaries,csharpcode,ffffff,kwrd,preproc,attr,lnum

0 comments:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Post a Comment

thank you for visiting my blog and comment here. I hope the commentary contains a comment which intend to build and repair. criticism and suggestions I gladly accept.

Popular Posts

 

Total Pageviews

stat

© Copyright 2010. http://programminghaha.blogspot.com . All rights reserved | http://programminghaha.blogspot.com is proudly powered by Blogger.com | Template by o-om.com - zoomtemplate.com