We can include external files for PHP, javascript, and css. Using external files is really good for us because we can save a lot of time coding by using it more and more time.
For example, you have already make a css file to custom your html code for all your web page, then you can just link it to every page on your html file. So if you want to change the color of your web page background, you just need to change only 1 file and it will affected to all your web page. Here is the way to include external file.
For php:
include ("filename.php");
require ("filename.php");
include and require are same but they are different when there is an error occurs.
include will generate warning but it continues the script. require will generate fatal error and stop the script.
For javascript:
<script type="text/javascript" src="filename.js"></script>
For css:
<link rel="stylesheet" type="text/css" href="filename.css" />
Hope this can help you
Welcome visitors of MIC Computer
Monday, March 19, 2012
Include external files for php, javascript, and css
posting by Michael at 1:48 PM 1 comment
Labels: CSS, Javascript, PHP
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 |
| 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 |
| 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 |
| 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
posting by Michael at 11:59 AM 0 comment
Labels: Javascript
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)the above example is a PHP procedure. Althougt you see that the declaration is function :). This is the example of PHP function.
{
echo(message);
}
function hello(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..
{
return("my message is " . message);
}
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
?>
we can also use this:
For Javascript we use
For CSS we use
</style>
posting by Michael at 10:47 AM 0 comment
Labels: CSS, Javascript, PHP
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.
- always use semicolon ";" at the end of each command line
- usually case sensitive
- use bracket for block command like this
if (some condition)
{
} else {
}
- 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:
- a name must start with letter or underscore "_"
- a variable name must contain only alpha-numeric characters or underscore (a-z, A-Z, 0-9, _ )
- we cannot use space for variable name but we can use _ or with capitalization ($my_var or $myVar)
- php variable is case sensitive