Tampilkan postingan dengan label PHP Tutorial. Tampilkan semua postingan
Tampilkan postingan dengan label PHP Tutorial. Tampilkan semua postingan

Kamis, 19 September 2013

Example Project of Condition

this thread contained an Example Project of Condition, before following this
tutorial, if you not knowing about Condition, read my post before about 
Condition, Array and Looping.

1. Create new HTML Document on your Site, Right Click on Site -> New File ->
name it "conditional_form.html" or what ever you want.

2. Insert this in your HTML form:
3. Create new PHP Document on your site, Right Click on Site -> New File -> name it "conditional".php" or what ever you want.
4. we create a variable to store the data sent, then checks whether the data is sent empty or not. If you do not check the selected gender, Add this code inside 'conditional.php.
5. Before test for Run, if you use Dreamweaver, please check 'Follow Links Con- tinously' and 'Use testing server for Document Source' first, this needed when you want appear in Live, that setting at "conditional_form.html".
6. And try to Run it in Live mode :
7. So the output will be seen like this :)

Rabu, 11 September 2013

Condition, Array and Looping at PHP

1. Condition
There's 3 way to make Condition at PHP: if, else, elseif. Every Condition
starting with if :

if(codition) {
//do something
}

if included else:

if(codition) {
//do something
}
else {
//do something else
}

else can be used to add more condition:

if(codition1) {
//do activity1
}
elseif(condition2) {
//do activity2
}
else {
//do other activity
}

*if the condition correct or true values of the existing code in the curly
braces {} will be executed.

2. Array
not seems like string and number only can hold a single value, array can
store/save more than one value. Values ​​can be accommodated, like string,
number, or other arrays. To make arrays in PHP as follows:

$country=array("Indonesia","Japan", "Singapore", "Australia");

or

$country[0]="Indonesia"; 
$country[1]="Japan"; 
$country[2]="Singapore";


-> to create an empty array:

$country=array();

-> to access the value inside array:

$var=$country[1];
echo $var; //the output is Japan
echo $country[0]; //the output is Indonesia

-> sorting array can using with function sort():


sort($country); //array sorted ascending
$var=$country[1]; 
echo $var; //the output is Japan
echo $country[0]; //the output is Indonesia


-> to knowing a lot of elements / or stored values array, using function
   count():

$Amount = count($country);
echo $Amount; //the output is 3


3. Looping
In PHP there are two forms of repetition that is often used, for and while,

-> Looping using for:

for(initial expression; condition; final expression){
//do something
}

Example:
for($i=1; $i<=10; $i++){
echo "Output >,<" ;
}
*this looping will outputing word "Output >,<" ten times.

-> Looping using while:

while(condition){
//do something
}

Example:
$i=1;
while($i<=10){
echo "Output >,,<";
$i++;
}
*this looping will outputing word "Output >,,<" ten times.

"as long as the conditions TRUE, the loop will continue to do"

Senin, 02 September 2013

Make Biodata Using Array 1 Variable on PHP

On this thread i want to share about make a biodata using array, but now
im only using one variable to difine the variable.

Firstly to remember about array, Array is a structured data type is useful
for storing large amounts of data of the same type.
Section assembles an array called Array Elements.

OK here's about my example, im using the old project of my biodata, if you
having it too, change only the variable,

the Screenshot of Code:

and looks at unprocess words, there's the right variable, on here we try to make it in one variable, and only add an index array for make the system different output with one variable. but the Output still same:
ok i think enought about this tutorial, thanks anyway..

Example Project Writing Style on PHP

Before scrutinizing this thread read first about Writing Style on PHP,

so, now i want to share about the example project using Style on PHP,

here the Screenshot of my Biodata project, on here we'll know about
the different things for using any output command, like echo, print,
printf,

here the Live view of Dreamweaver

here the code, you can do it too with your modify self project
and there's the view of localhost on browser
ok time for you to learning and try it now, and one thing again, don't forget about add Header ('Content-type: text/plain');

Writing Style on PHP

In this thread i want to share about "Writing Style on PHP".

1. Echo
echo : used to print variable or character string without using format.
how to use:
echo "right";
echo ("right");

example:
$flname=Bagoes Rizaldy Setiambodo;
echo ("My Full Name is : %flname");


2. Print and Printf

Print : used to print variable or character string without using format.

example:
$flname=Bagoes Rizaldy Setiambodo;
print ("My Full Name is : %flname");

Printf : used to print variable or character string using format.

-> for String format use  : %s
-> for Integer format use : %d
-> for Decimal format use : %f

example:
$flname=Bagoes Rizaldy Setiambodo;
printf ("My Full Name is : %s",%flname);

echo does not have a return value while print has a return value that is
worth the amount of characters displayed.

3. Define constanta

for defining constanta, we just need tag:

define("name_constants",constants_values);

Arithmetic operators:
$a + $b = Addition (total of $a and $b)
$a - $b = Reduction (reduction of $a and $b)
$a * $b = Multiple (multiple of $a and $b)
$a / $b = Division (quotient of $a and $b)
$a % $b = Modulus (remainder of $a division $b)

Logic operators:
$a and $b = And (TRUE if $a and $b TRUE)
$a or $b  = Or (TRUE if $a or $b TRUE)
$a xor $b = Xor (TRUE if one of $a or $b TRUE)
  !$a     = Not (TRUE if $a not TRUE)
$a && $b  = And (TRUE if $a and $b TRUE)
$a || $b  = Or (TRUE if $a or $b TRUE)

Comparison operators:
$a == $b  = Equal (TRUE if $a = $b)
$a === $b = Identical (TRUE if $a = $b, and have same type)
$a != $b  = Not Equal (TRUE if $a not= $b)
$a <> $b  = Not Equal (TRUE if $a not= $b)
$a !== $b = Not identical (TRUE if $a not= $b, or have different type)
$a < $b   = Less than (TRUE if $a less than $b)
$a > $b   = Greater than (TRUE if $a greater than $b)
$a <= $b  = Less than or Equal to (TRUE if $a less than or same $b)
$a >= $b  = Greater than or Equal to (TRUE if $a greater than or same $b)

On the next Thread i'll share about the example project :)

Rabu, 21 Agustus 2013

Make PHP using Variable

In this thread i want to share about make Biodata with collaboration PHP and
HTML script with using Variable technique.

i'm ever share before about using Variable on PHP. so, if you ever read more
easy for make it:

This slice of screenshot for the Script:

On the top of script we will found the PHP script, on there i take the Defini tion for the Variable. Under the PHP script it's HTML script for outputing, and inside table tag we include PHP script for make the Variable works. this Biodata looks like:

PHP Variable String and Number

PHP has 8 type data of Variable: Boolean (True - False), Integer, Floating
point(decimal), String, Array, Object, Resource, and Null.

In this page i want to explain about using Variable with String in PHP:

There some rule for writing Variable in PHP:

- Writing PHP variable begins with '$' (dollar) character.
- When it included with 2 words, dont input  between both, you can use '_'
(underscore) or combine that 2 words.
- The Character must letter or underscore after '$', cant use Number or Symbol.
- Variable in PHP is Case-sensitive.

Example: $variableName
         $variable_Name
         $variableName with $Variablename is Different.

When we want to fill and show the values of a Variable where the type data is
"String", it need ';' for ending. And if we want include words inside the
command viewer we must use " (double quote).

Example: echo $variableName;
         print $variableName;
         echo "Hi, $variableName";

Here Example for writing Variable with String type data:

< ?php
$fullName = " Bagus Rizaldy S";
echo "My Full Name is$fullName";
echo "My Full Name is".$fullName";
?>

the output will be appear like this:

so, the explanation is we call the contents of the Variable, when we want to combine the Variable and String we must put "." between it. And then try to Number or Numeric: < ?php $number1 = 2; $number2 = "3"; $number3 = "4four"; echo "$number1*$number2"; echo $number1*$number2; echo $number1+$number3; ?> the output will be appear like this:
so, the explanation is see on first output it appear 2*3, why it is not calculate? becuse it use quotes so it detected as string, only appearing and not calculate it, so if you want to make calculate Number or Numerical dont put any quotes like at operaion number 2 when the output 6, so if we didnt put qoutes the letter wont to detect like variable $number3.

Jumat, 02 Agustus 2013

Open file in internal browser at phpDesigner8


Tutorial PHP at phpDesigner8
In this page i'll share how to open .php file in internal
browser from phpDesigner8 software.

1. Open your phpDesigner and Project --> Project Manager

2. And then will approach 'Project Manager' click 'New' fill your 'Project Title:' and click 'Next'
3. After that we need to fill our 'Project Root Folder' fill the destination of folder and click 'Next'
4. we done about 'Project folder setting' and then we go to localhost tab, fill your localhost,local path, and your localhot port then click 'Ok'
5. and last steps, open your php project, click 'Run' and this project will appear on internal browser.

Kamis, 01 Agustus 2013

Open File with 'Shift+F6' to External Browser at NetBeansIDE


Tutorial PHP at NetBeansIDE
In this page i'll share how to open .php file with software NetBeansIDE
and use 'Shift+F6' open files to External browser(im using Firefox)

1. Open your NetBeansIDE and 'New Project...'. On tab steps '1. Choose Project'
   categories 'PHP' select Project and hit 'Next'

2. Now tab 'Name and Location' fill the Sources Folder with file directory and hit 'Finish'
3. File directory opened, and Properties
4. On tab Categories choose 'Run Configuration' look at 'Project URL' change the address localhost port if you change it and hit 'Ok'
5. change you External browser opener: Tools --> Options
6. Open subProject choose file and hit 'Shift+F6' and look at your browser the file opened!

Tutorial Change Apache Port


How to change Apache Port
If it can't to running we must change our Apache Port to 24(for my example,
whatever you want to change the port) for one reason, for example because it
clashed with IIS(Internet Information Service)

1. go to your xampp directory: (C:\xampp\apache\conf)

2. search file named: "httpd.conf" and open to edit
3. search "Listen 80" (default)
4. and change only Listen 80 what ever you want for my example i change it to Listen 24
5. save it, and Restart your Apache server 6. Done!

Rabu, 31 Juli 2013

Live View and Browser external at Dreamweaver


Tutorial PHP at Dreamweaver

If it can't to running we must change our Apache Port to 24(for my example,
whatever you want to change the port) for one reason, for example because it
clashed with IIS(Internet Information Service).Tutorial

1. Make PHP file in folder -> xampp/htdocs/PraktikumPHP/latihan1.php. 
   Create a program featuring "Hello World, my name is bla bla..."

2. Open your Dreamweaver

3. Click New Site
4. On "Site" Tab, fill your "Site Name" and "Local Site Folder" for example:
5. On "Servers" Tab. fill your "Server Name" for my example "Server Name : localhost24" 24 on here is the Apache port. so, on "Web URL" we need to change it to http://localhost:24/PraktikumPHP/
6. and you will see the "Live View" on your Dreamweaver:
7. from External Browser: