Welcome visitors of MIC Computer

Welcome to my blog. With this blog you can post your question about computer and programming for absolutely free (free consultation sponsored by MIC Computer).. Well what are you waiting for just feel free to post your question or share with me about your computer / programming experience

Friday, October 28, 2011

PHP, Javascript, Java, and other C# style language Operators


Arithmetic Operators
Operator Description Example Result
+ Addition x=4+3 x=7
- Subtraction x=10-3 x=7
* Multiplication x=2*9 x=18
/ Division x=6/2
y=5/2
x=3
y=2.5
% Modulus (division remainder) x=7%2
y=9%3
z=10%4
x=1
y=0
z=2
++ Increment x=8;
x++;
x=9
-- Decrement x=8;
x--;
x=7
Assignment Operators
Operator Example Equivalent
= x=y x=y
+= x+=y x=x+y
-= x-=y x=x-y
*= x*=y x=x*y
/= x/=y x=x/y
.= x.=y x=x.y
%= x%=y x=x%y
Comparison Operators
Operator Description Example
== is equal to 2==2 returns true
3==2 returns false
!= is not equal 2!=2 returns false
3!=2 returns true
<>
is not equal (only at PHP) 2<>2 returns false
3<>2 returns true
> is greater than 2>3 returns false
3>2 returns true
< is less than 2<3 returns true
3<2 returns false
>= is greater than or equal to 2>=2 returns true
2>=3 returns false
3>=2 returns true
<= is less than or equal to 2<=2 returns true
2<=3 returns true
3<=2 returns false
Logical Operators
Operator Description Example
&& and x=2
y=3 (x < 5 && y > 2) returns true
|| or x=2
y=3 (x < 1 && y > 2) returns true
! not x=2
y=3 !(x==y) returns true

Wednesday, October 26, 2011

Javascript Procedure and Function

As an programming language that support OOP, Javascript also have procedure and function. Procedure and function on javascript has the same format like PHP and any other C++ style language.

function procedure_and_function_name(var1,var2,...,varX)
{
javascript code
}

As you can see procedure and function format has the same format. The different is function has a statement like this:

Return(variable_or_value);
 here is some example:
Example of procedure:
function message(message_contain)
{
alert("This is my message "+message_contain);
}

Example of function:
function message(message_contain)
{
return("This is my message "+message);
}
echo(message("Hello friend"));

Hope this can help you

Monday, October 10, 2011

PHP Procedure and Function I

Every object oriented programming (OOP) should need a procedure and function. PHP is also OOP so it also need procedure and function. To declare a procedure or function, we have a same format

function hello(message)
{
echo(message);
}
the above example is a PHP procedure. Althougt you see that the declaration is function :). This is the example of PHP function.
function hello(message)
{
return("my message is " . message);
}
this is a PHP function, can you see the different? Yes you are right. The different is there is return statement as a return value on PHP function. That's all..

Thursday, September 29, 2011

PHP, Javascript, CSS block scripting

How can server, browser or we can recognise what kind of script at an HTML document? We use some block scripting to open and end it up.
For PHP we use

<?php
php script goes here
?>
we can also use this:
<?
php script goes here
?>
but I always use <?php and ?>

For Javascript we use
<script type="text/javascript">
Javascript script goes here
</script>
we can also use this
<script>
Javascript script goes here
</script>

For CSS we use
<style type="text/css">
CSS style goes here
</style>

Some really basic C# style language (PHP,JavaScript,Java, etc)

Here is some basic rule for some C or C# style language like PHP, Java, Javascript, etc.

  1. always use semicolon ";" at the end of each command line
  2. usually case sensitive
  3. use bracket for block command like this
    if (some condition)
    {
    } else {
    }
  4. can use quote ' or double quote " for string variable like this "my string" or 'my string'

PHP Variable

PHP also have a variable to store temporary data. Just like Javascript variable, PHP variable can store anykind of data in 1 variable. For example, you can store 234 (number) in a variable and then change it to "Hello" (string) later.
PHP have some rule if you want to declare a variable:

  1. a name must start with letter or underscore "_"
  2. a variable name must contain only alpha-numeric characters or underscore (a-z, A-Z, 0-9, _ )
  3. we cannot use space for variable name but we can use _ or with capitalization ($my_var or $myVar) 
  4. php variable is case sensitive

Wednesday, September 14, 2011

Comment

Comment is very important for programmer. Every languages have a comment. This is a comment of some language:

  1. Visual Basic
    • single line '
  2. PHP
    • single line //
    • block /* block comment */
  3. Javascript
    • single line //
    • block /* block comment */
  4. XML
    • single line //
    • block /* block comment */
  5. HTML
    • block <!-- block comment -->

Javascript variable

As any other language, javascript is also has variables. Javascript is case sensitive, so the variable name is case sensitive too. So y variable is different with Y. Javascript variable name must begin with letter or underscore.

This is how you declare javascript variable:
Local Variable:
Has to be declare inside a function. Example:
<script type="text/javascript">
function print_hello()
{
var somewordempty;
document.write("empty " + somewordempty + "<br/>");
somewordempty="assign value to empty";
document.write(somewordempty + "<br/>");
var somewordassign ="assigned variable";
document.write(somewordassign + "<br/>");
}
print_hello();
</script>
Global Variable:
Has to be declare outside functions. I hope this example can make you understand. Example:
<script type="text/javascript">
var globalvar=" <br/>should be global";
document.write(globalvar);
function print_hello()
{
var globalvar="<br/>should be local, because although it have the same name but it declares under a function";
document.write(globalvar);
}
print_hello();
document.write(globalvar + " because it outside the function");
</script>
Let's try to call it again and you will get the same value as above. Because global variable is destroy when we close this page.
<script type="text/javascript">
document.write(globalvar);
</script>

Thursday, September 8, 2011

My First XML

XML stand for eXtention Markup Language. XML has make a big different on the web programming and application. By learning XML we can communicate with a lot of different application language, web or desktop programming language. If you want to learn ajax, XSL, DOM, XHTML, web service, RSS, etc, than you need to learn or know about XML. XML can help us to separate display and data. The different betweenjavascript:void(0) XML and HTML is HTML is for display and XML is for the data. XML store and transfer the data.

Now lets start learning. This is the example of XML document:
<?xml version = "1.0" encoding = "utf-8"?>
<computer>
    <PC>
        <mainboard>
            <processor>
                       <manufacture>Intel</manufacture>
                       <type>Core 2 duo</type>
            </processor>
            <memory type="DDR3">
                    <manufacture>VGEN</manufacture>
                    <capacity>2G</capacity>
            </memory>
        </mainboard>
        <sound_card type="onboard" />
        <vga_card type="onboard" />
    </PC>
    <PC>
        <mainboard>
            <processor>
                       <manufacture>AMD</manufacture>
                       <type>Turion</type>
            </processor>
            <memory type="DDR3">
                    <manufacture>VGEN</manufacture>
                    <capacity>2G</capacity>
            </memory>
        </mainboard>
        <sound_card type="PCI Express" />
        <vga_card type="PCI Express" />
    </PC>
</computer>
Well this data is just an example. But it show us how to make it.
This is the rule to make an XML document:

  1. XML document need this at the first of the document <?xml version = "1.0" encoding = "utf-8"?>
  2. encoding = "utf-8" show us how this XML document should be displayed
  3. XML document need to have a root element. In our example, the root element is <computer>.
  4. XML document should be well formed. It is mean that we should put closed tag on every element. As you can see that if we have open a tag like <mainboard>  than we have to close it </mainboard>. But how about a single element like sound_card and vga_card? The syntax to open and close it is like this <sound_card type="anything" / >
  5. A parameter need to be open and close using " or ' like this <sound_card type="anything" />

Sunday, September 4, 2011

Mainboard

Today I want to share about what is Computer Mainboard. Every computer have a mainboard. What is mainboard? Simple explanation, mainboard is a place where we put/connect every computer other componen. We put memory, VGA Card, Sound Card, we also connect the harddisk, DVD ROM every thing on the mainboard.

This is a picture of a mainboard I take from wikipedia (http://en.wikipedia.org/wiki/Motherboard)
This is the diagram of a mainboard, I take this diagram from wikipedia also (http://en.wikipedia.org/wiki/Chipset):

  1. CPU (Processor)
  2. Memory (RAM)
  3. BUS (FSB etc)
  4. Northbridge Chipset
  5. Southbridge Chipset
  6. VGA
  7. other IO (Input Output)
  8. BIOS
  9. RTC (Real Time Clock)
CPU / Processor
CPU is what we call processor, this is the "brain" of the computer. Its process every thing, that need to be calculating, making decision and everything.

Memory
Memory /RAM is a volatile memory that CPU use to store fast temporary data for the processor. There is a lot of type of it, EDO RAM, SDRAM, DDR 1, DDR 2, DDR 3,etc.

BUS
Bus is the path to link every component of the mainboard. A bus that linked the CPU from the northbridge chipset is very special, and we call it FSB(Front Side Bus). This is a fast BUS because CPU is very fast and it needs a very fast BUS also to avoid bottleneck.

Chipsets
Chipsets if very important for a mainboard/motherboard, because they control everything on the mainboard. Well I want to say that they are the "backbone" of the computer. There is 2 kind of chipsets:
  1. Northbridge 
  2. Southbridge
The Northbridge Chipset control the "fast" components of the mainboard, they are:
  1. CPU
  2. Graphic Card (Onboard or external graphic slots like AGP of PCI Express)
  3. RAM
The  Southbridge Chipset control the "slow" components of the mainboard like:
  1. PCI or ISA slots
  2. PATA or SATA slots (we use it to connect the hard disk to the mainboard)
  3. USB
  4. Sound Card
  5. LAN Card
  6. RTC
  7. BIOS
  8. etc
BIOS
BIOS is the unvolatile memory on the mainboard. It used to tell the CPU what it should do when the computer begin to start. It also store the setting of the computer, like to turn on or off onboard device, setting the boot priority etc.

RTC
RTC is a clock that will always run event when the computer is turned off. That is why your computer clock is always show the correct time, event if you shut it down.

      Friday, September 2, 2011

      Basic HTML elements

      This is some basic HTML elements:
      Heading:
      <h1>This is heading 1</h1>

      This is heading 1

      <h2>This is heading 2</h2>

      This is heading 2

      <h3>This is heading 3</h3>

      This is heading 3


      Paragraph:
      <p>This is paragraph</p>
      This is paragraph

      Link:
      <a href="http://mic-computer.blogspot.com">This is a link</a>
      This is a link, try to click it

      New Line:
      <br> or <br/>
       Horisontal Line:
      <hr> or <hr/>


      List:
      Ordered List:
      <ol>
      <li>Number 1</li>
      <li>Number 2</li>
      <li>Number 3</li>
      </ol>
      1. Number 1
      2. Number 2
      3. Number 3
      UnOrdered List:
      <ul>
      <li>Number 1</li>
      <li>Number 2</li>
      <li>Number 3</li>
      </ul>
      • Number 1
      • Number 2
      • Number 3
      Definition List
      <dl>
      <dt>Title Number 1</dt>
      <dd>Description Number 1</dd>
      <dt>Title Number 2</dt>
      <dd>Description Number 2</dd>
      <dt>Title Number 3</dt>
      <dd>Description Number 3</dd></dl>
      Title Number 1
      Description Number 1
      Title Number 2
      Description Number 2
      Title Number 3
      Description Number 3
      Tips:
      1. Don't forget to use the end tag for some elements that need it like:
      <h1>This is header 1
      2. For a single element like <br>, you should use <br/> for XHTML.

      My First HTML

      Website now is the part of our life. To make a website the first thing we have to know is HTML. HTML is so simple, it can be write and make only using a simple editor like notepad or wordpad. You can also make HTML document using an expert editor like macromedia dreamweaver or microsoft frontpage. HTML document have a file extensions .htm or .html.

      HTML document is also very simple, it contain:

      1. head
      2. body
      this is the example of it:
      <html>
      <head><title>My First HTML</title></head>
      <body>
      Hello World
      </body>
      </html>
      this is a hello world HTML document. Just type it on notepad and save it as first.html or first.htm

      My First Javascript

      Javascript was designed by Brendan Eich at Netscape (with Navigator 2.0) and was used on all browser on 1996. Javascript is an implementation of the ECMAScript language standard and ECMA-262 is the official JavaScript standard. If PHP is a server side programming language, Javascript is a client side programming language. It has the same function like VBscript.

      Javascript is different with java, although they have a lot of same function and syntax. What is the different between javascript, HTML and PHP? You know if you use HTML you cannot make a dynamic page. If you use PHP, you have to refresh the page if you want to update the page. If you use javascript than you can update the page without press the refresh button.

      This is our first javascript program:
      Hello World

      <html>
      <head>
      <title>My First Javascript</title>
      </head>
      <body>
      <script type="text/javascript">
      document.write("Hello World");
      </script>

      </body>
      </html>
       
      Write this code and save it as javascript.html

      Wednesday, August 31, 2011

      My First PHP

      PHP (PHP: Hypertext Preprocessor) is a server side language (have the same function like ASP, ASP.NET, of JSP). For the first time PHP development began in 1994 when Rasmus Lerdorf made some set of perl script that he called as "Personal Home Page Tools" to maintain his `Personal Home Page`. In 1997 Zeev Suraski and Andi Gutmans, two Israeli developers rewrote the parser and formed the base of PHP3. The PHP3 was launch in June 1998 and Zend Engine was found in 1999.

      PHP is a popular server side language on Linux but now we also use it on Unix, Windows and Macintosh. For the first time it was designed to run with Apache web server, but now we can run it using PWS (Personal Web Server), IIS (Internet Information Server) and Xitami.

      Why we use PHP?
      We use PHP to generate a dynamic HTML page. As you already know that HTML page is a static page that can only display a static information. For example you cannot display a page that show a timestamp but PHP can do it although you have to refresh the page anytime you want to see the new timestamp.

      How PHP works?

      1. when user open a web page, the request was send to the web server.
      2. web server then search and execute the PHP script
      3. PHP script then produce the HTML code and send it back to the client browser
      How to install PHP?
      I will show you how to install PHP on Windows now.
      1. to install PHP on windows is very simple now. you can download and install a free web server software like XAMPP or WAMP here.
      2. install and follow the instruction.
      3. turn on your web server
      4. and you are ready now, just open your browser and type "http:\\localhost" that's all
      Hello world
      Lets make our first PHP script. But first I want to show you the similar HTML script that produce the same page on your browser. First write this code to an editor like notepad/wordpad. Then save it as first.html for html and first.php for PHP. Then open your browser and open it. (I will explain about how to open it in other topic. But you can open XAMPP/WAMP web site to do this)
      HTML:
      <html>
      <head>
      <title>My first PHP</title>
      </head>
      <body>
      Hello World
      </body>
      </html>

      PHP:
      <html>
      <head>
      <title>My first PHP</title>
      </head>
      <body>
      <?php
      echo("Hello World");
      ?>
      </body>
      </html> 
       So why that we have to use PHP? try this script:
      HTML:
      <html>
      <head>
      <title>Today Date</title>
      </head>
      <body>
      For example here just write some date because HTML can't do that.
      2011 September 01
      </body>
      </html>

      PHP:
      <html>
      <head>
      <title>Today Date</title>
      </head>
      <body>
      PHP can show the server time correctly, just refresh your page to update it.
      <?php
      echo(date("Y F d"));
      ?>
      </body>
      </html>
       Now I hope you will understand why we have to use PHP for dynamic HTML page :).