d

sdddfsfa

Posted in Uncategorized | Leave a comment

PHP- day2

Basic Syntax

<?php

if($true)

{

echo “true”;

}

else

{

echo “false”;

}

?>

 

<?php

if($true)

echo “true”;

else

echo”false”;

?>

<?php

if($true):

echo”true”;

else “false”;

endif;

?>

<?php if(condition):?>

<?php else:?>

<?php endif;?>

 

<?php

//output the answer by escape

if($true_or_false){

?>

<p>The value of $true_or_false is true.</p>

<?php

}else{

?>

<p>The value of $true_or_false is false.</p>

<?php

}

 

if ($true_or_false){

echo’<p>the value of $true_or_false is ture.</p>’;

}else {

echo’<p>The value of $true_or_false is false.</p>’;

}

When PHP parses a file, it looks for opening and closing tags, which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser. Most of the time you will see PHP embedded in HTML documents,

Escaping from HTML

<P>This is going to be ignored .</p>

<?php echo ‘While this is gong to be parsed.’; ?>

<p>This will also be igonred.</p>

 

Example # Advanced escaping

<?php

if($expression){

?>

<strong>This is true.</strong>

<?php

}else{

?>

<strong>This is false.</strong>

<?php

}

?>

PHP opening and closing tags

<?php echo ‘if yo uwant to server XHTML or XML documents, doit lik this’:”>

<script language=”php”>

echo ‘some editors (like FrontPage) don\’t

like processing instructions’;

</script>

<? echo ‘this is the simplest, an SGML processing instruction’;?>

<?=expression ?> This is a shortcut for”<? echo expression ?>”

<%echo ‘You may optionally use ASP-style tags’;%>

<%=$variable; # This is a shortcut for “<% echo . . . “%>

 

Instruction separation

As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement. The closing tag of a block of PHP code automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block. The closing tag for the block will include the immediately trailing newline if one is present.

 

<?php

echo ‘This is a test’;

?>

<?php echo ‘This is a test’?>

<?php echo ‘’We omitted the last closing tag’;

 

Comments

PHP supports ‘C’, ‘C++’ and Unix shell-style (Perl style) comments. For example:

<?php

echo’ This is a test’; //This is a one-line C++ style comment

/*This is a multiple line comment

yet another line of comment*/

echo ‘This is yet another test’;

echo’ One final Test’; # this is one line shell –style comment

?>

 

___________________________________________________________________________________

Types

 

PHP offers the usual basic primitive types which can hold one piece of data at a time.

<?php

class Person

{

$firstName; //a PHP string

$middleName; //a PHP string

$lastName; //a PHP string

$age; //a PHP Integer

$hasDriversLicense; //a PHP Boolean

}

?>

<?php

$myAge = 16;

$yourAge = 15.5; //a php Float

$hasHair = true; //a PHP Boolean

$greeting =”Hello World”!”

$person = new Person(); // a PHP pserons –available

?>

http://www.php.net/manual/en/language.oop5.php

Object oriented

Classes and Objects

http://www.php.net/manual/en/oop5.intro.php

Starting with PHP 5, the object model was rewritten to allow for better performance and more features. This was a major change from PHP 4. PHP 5 has a full object model.

Among the features in PHP 5 are the inclusions of visibility, abstract and final classes and methods, additional magic methods, interfaces, cloning andtypehinting.

PHP treats objects in the same way as references or handles, meaning that each variable contains an object reference rather than a copy of the entire object. See Objects and References

http://www.php.net/manual/en/language.oop5.references.php

objects are passed by references by default

 

References and Objects

<?php
class A {
    public $foo = 1;

$a = new A;
$b = $a;     // $a and $b are copies of the same identifier
             // ($a) = ($b) = <id>
$b->foo = 2;
echo $a->foo.”\n”;
$c = new A;
$d = &$c;    // $c and $d are references
             // ($c,$d) = <id>
$d->foo = 2;
echo $c->foo.”\n”;
$e = new A;
function foo($obj) {
// ($obj) = ($e) = <id>
$obj->foo = 2;
}
foo($e);
echo $e->foo.”\n”;
?>

<?php
class A{
public $foo =1;
}

$a = new A;
$b = $a; //$a and $b are copies of the same identifier

$b –>foo =2;
echo $a->foo.”\n”;

$c = new A;
$d =&$c; //$c and $d are references
//($c,$d)=<id>

>$d = new A;
function foo ($obj ){
//)$obj)=($e) =<id>

$obj->foo =2;
}

foo($e);
echo $->foo.”\n”;

?>

Objects and

reference Exercise

http://www.php.net/manual/en/language.oop5.references.php

 

Arrow Operator:

http://ch2.php.net/manual/en/language.oop5.static.php

 

the :: is the scope resolution operator which allows access to static, constant, and overridden members or methods of a class.
the -> arrow operator is used to get at the variables and functions that belong to an object.

객체없이 화살표 쓰는 이유

아래 라인이 바로 객체를 생성하는 부분입니다.

@$db = new mysqli(‘localhost’,’ID’,’PW’,’TABLE’);

new 라는 지시어로 시작하는 것은 모두 객체를 생성하는 것입니다.

그리고 mysqli 는 PHP5 버전 부터 지원이 되며 기존의 구조적 프로그램과 객체지향적 프로그램 모두를 지원하기 때문에 프로그래머가 익숙한 방법을 사용하시면 되는 것이죠.

위와 같이 $db 에 새로운 객체를 생성하고…

아래와 같이 쿼리를 실행하면…

$result = $db->query($query);

그 결과 역시 객체로 리턴 받게 됩니다.

 

Booleans

http://www.php.net/manual/en/language.types.boolean.php

boolea literal,use the keywords TRUE or FALSE.. Both are scase –insenstive.

<?php
$foo = True;//assign the value TRUE to $foo
?>

Typically, the result of an operator which returns a boolean value is passed on to a control

structure.

<?php
//== is an operator which tests
//equally and returns a boolean
if ($action == “show_version”){
echo “The version is 1.23”;
}

http://www.codecoffee.com/tipsforlinux/articles2/041-php5.html

<?php
function booNumber($bValue = false){ //return integer
  return ($bValue ? 1:0);
  }
 
function boolString($bValue = false){ //return string
return ($bValue ?’true’ : ‘false’); //return string
}
 
$a = true;
echo ‘boolean $a AS string =’.boolString($a).'<br>’;//boolean as a string
echo ‘boolean $a AS number = ‘.boolNumber($a). ‘<br>’;//boolean as number
echo'<br>’;
 
$b = (45>90);
echo ‘boolean $b AS string =’.boolString($b). ‘<br>’; //boolean a string
echo ‘boolean $b AS number =’.boolNumber($b).'<br>’; //boolean as a number
$c = boolNumber (10>8) + boolNumber(!(5>10)); //adding booleans
echo ‘integer $c =’.$c.'<br>’;
?>
Rsults in the following being printed…
 
In other words, if we know what we want out of our program, we can create functions to accommodate.
Here, we just wanted ‘manual control’ over numbers and strings, so that PHP doesn’t confuse us.
 
 
 
 
<?php

function boolNumber($bValue = false) {                      // returns integer
  return ($bValue ? 1 : 0);
}

function boolString($bValue = false) {                      // returns string
  return ($bValue ? ‘true’ : ‘false’);
}

$a = true;                                                  // boolean value
echo ‘boolean $a AS string = ‘ . boolString($a) . ‘<br>’;   // boolean as a string
echo ‘boolean $a AS number = ‘ . boolNumber($a) . ‘<br>’;   // boolean as a number
echo ‘<br>’;

$b = (45 > 90);                                             // boolean value
echo ‘boolean $b AS string = ‘ . boolString($b) . ‘<br>’;   // boolean as a string
echo ‘boolean $b AS number = ‘ . boolNumber($b) . ‘<br>’;   // boolean as a number
echo ‘<br>’;

$c = boolNumber(10 > 8) + boolNumber(!(5 > 10));            // adding booleans
echo ‘integer $c = ‘ . $c .'<br>’;

?>

 

 

 

 

 

<?php
var

 

String

http://www.php.net/manual/en/language.types.string.php
A String is seriso of characters, where a character is the same as a byte.
This means that PHP only supports a 256 – character set, and hence does not offer
Native unicode

 

Syntax

A string literal can be specified in four different ways:

single quoted
double quoted
heredoc syntax
nowdoc syntax (since PHP 5.3.0)

<?php
echo ‘this is a simple string’;

echo ‘You can also have embedded newline in string this way as it is ok’;

echo ‘ Arnold once “I will be back’

Posted in Uncategorized | Leave a comment

PHP Manual

http://www.php.net/manual/en/langref.php

 

Language Reference

Posted in Uncategorized | Leave a comment

18-02-2012

10AM to 3PM Training

  • Installation of VMware (VMware player is not stable as VMware studio)
  • Ampal installation
  • Ampal configuration
  • Ampal event manager
  • Ampal virutal motor, Down time configuration
  • Ampal PLC Scada configuration to simulation
  • Ampal simulation of motor
  • Ampal domain (BHP-Gladstone, Brisbane ,Gold coast) ordering configuration

VMware

  • VMware IIS installation

Testing

  • HP Testing
Posted in Uncategorized | Leave a comment

check the user agent string the browser sends

We can check the user agent string the browser sends as part of the HTTP request.

Where that information is stored in ?

(in a variable)

Variable is always started with(                   )?

(a dollar –sign in PHP)

$_SERVER is a special (                        )PHP variable.

(reserved)

that contains (                               ) information.

(we server)

 

How to printing a variable (Array element)

<?php

echo $_SERVER[‘HTTP_USER_AGENT’];

?>

can put multiple PHP statements inside a PHP tag and create little blocks of code that do more than just a single echo

<?php
if (strpos($_SERVER[‘HTTP_USER_AGENT’], ‘MSIE’) !== FALSE) {
    echo ‘You are using Internet Explorer.<br />’;
}
?>

 

The second concept we introduced was the strpos() function call. strpos() is a function built into PHP which searches a string for another string. In this case we are looking for ‘MSIE’ (so-called needle) inside $_SERVER[‘HTTP_USER_AGENT’] (so-called haystack).

 

With your new knowledge you should be able to understand most of the manual and also the various example scripts available in the example archives. You can also find other examples on the php.net websites in the links section: » http://www.php.net/links.php.

To view various slide presentations that show more of what PHP can do, see the PHP Conference Material Site: » http://talks.php.net/

Posted in Uncategorized | Leave a comment

Get system information from PHP

<?php phpinfo();?>

Posted in Uncategorized | Leave a comment

Write PHP code inside of HTML code with echo’ ‘;

 

1. Write code HTML code inside of echo’ ‘ ; h2

2. Write code HTML code inside of echo’’; h3 ,h4,h5

 

http://www.php.net/manual/en/tutorial.firstpage.php

 

echo() statement.  The server finds out that this file needs to be interpreted by PHP  becuase of “.php” extension.

Posted in Uncategorized | Leave a comment

ex.1

Create a file named kang.php

and put it my server’s root directory(DOCUMENT_ROOT)

kang.php

<html>

<head>

<title>PHP test</title>

</head>

<body>

<?php echo ‘<p>Hello World</p>’; ?>

PHP 에코 안에서 ‘   ‘ ; html 을 넣는다.

</body>

</html>

Posted in Uncategorized | Leave a comment

PHP -1

<html>

<head>

<title>PHP Test</title>

</head>

<body>

<?php echo ‘<p>Hello World</p>’; ?>

</body>

</html>

Posted in Uncategorized | Leave a comment

Software testing.

Software testing

Posted in Uncategorized | Leave a comment