Variables in PHP

variables in php 

 declaring variables in php is very simple .its more easier then java and c++ to declare variable

•PHP variables must begin with a “$” sign 

ie $x         , $y

•Case-sensitive 

($Foo != $foo != $fOo) 

•Global and locally-scoped variables 

–Global variables can be used anywhere
–Local variables restricted to a function or class

•Certain variable names reserved by PHP

–Form variables ($_POST, $_GET)
–Server variables ($_SERVER)
–Etc.

•PHP is a loosely typed language

–In PHP, a variable does not need to be declared before adding a value to it
Example code
[code start]

<?php
$foo = 25;  // Numerical variable
$bar = “Hello”;  // String variable
$foo = ($foo * 7);  // Multiplies foo by 7
$bar = ($bar * 7);  // Invalid expression
?>

[code end]

Echo in php 

•The PHP command ‘echo’ 

is used to output the parameters passed to it
–The typical usage for this is to send data to the client’s web-browser

•Syntax

–void echo (string arg1 [, string argn...])
–In practice, arguments are not passed in parentheses since echo is a language construct rather than an actual function 
Example:

[code start]

<html>
<body>
<?php
echo "Hello World";
?>
 <br />
<?php
$txt="Hello World";
echo $txt;
?>
</body>
</html>

[code end]

Example2:
[code start] 
<?php
$foo = 25;  // Numerical variable
$bar = “Hello”;  // String variable
echo $bar;  // Outputs Hello
echo $foo,$bar;  // Outputs 25Hello
echo “5x5=”,$foo;  // Outputs 5x5=25
echo “5x5=$foo”;  // Outputs 5x5=25
echo ‘5x5=$
foo’;  // Outputs 5x5=$foo
?>

[code start] 

•Notice how echo ‘5x5=$foo’ outputs $foo rather than replacing it with 25
•Strings in single quotes (‘ ’) are not interpreted or evaluated by PHP
•This is true for both variables and character escape-sequences (such as “\n” or “\\”)


0 comments:

php vs c/c++ code structure comparison

What does PHP code look like?

What you will learn here.
1.How to escape from HTML and enter PHP mode 
2.Simple HTML Page with PHP 
3.Using conditional statements
4.Comments in PHP



Php code Structurally is similar to C/C++
Php scripting Supports procedural and object-oriented paradigm (to some degree) .
All PHP statements end with a semi-colon Each PHP script must be enclosed in the reserved PHP tag

learn php tutorials syntex



1.How to escape from HTML and enter PHP mode

•PHP parses a file by looking for one of the special tags that
tells it to start interpreting the text as PHP code. The parser then executes all of the code it finds until it runs into a PHP closing tag.
php with html embeded code
<?php echo “Hello World”; ?>

2.Simple HTML Page with PHP 

The following is a basic example to output text using PHP.



[code start]

<html><head>
<title>My First PHP script Page</title>
</head>
<body>
<?php
echo "Hello World!";
?>
</body></html> 

[code end]



Copy the code onto your web server and save it as “test.php”.

You should see “Hello World!” displayed. (if you dont know how to setup localhost/localServer then click here)

Notice that the semicolon is used at the end of each line of PHP code to signify a line break. Like HTML, PHP ignores whitespace
between lines of code. (An HTML equivalent is <BR>)

3.Using conditional statements

•Conditional statements are very useful for displaying specific content to the user. The following example shows how to display content according to the day of the week.  
[code start]
<?php
$today_dayofweek = date(“w”);

if ($today_dayofweek == 4){
echo “Today is Thursday!”;
}
else{
echo “Today is not Thursday.”;
}

?>
 [code end]


The if statement checks the value of $today_dayofweek
(which is the numerical day of the week, 0=Sunday… 6=Saturday)
•If it is equal to 4 (the numeric representation of Thurs.) it will display
everything within the first { } bracket after the “if()”.
•If it is not equal to 4, it will display everything in the second { } bracket
after the “else”. 

If we run the script on a Thursday, we should see:
“Today is Thursday”.

On days other than Thursday, we will see:
“Today is not Thursday.”
[code start]

<?php
$today_dayofweek = date(“w”);

if ($today_dayofweek == 4){
echo “Today is Thursday!”;
}
else{
echo “Today is not Thursday.”;
}

?>

 [code end]


4.Comments in PHP

•Standard C, C++, and shell comment symbols





[code start]

<?php
// C++ and Java-style comment
# Shell-style comments
/* C-style comments
These can span multiple lines */
?>
[code end]

Read next:

Variables in PHP



1 comments:

why php is used? benefits of using php

first read previous article

why php is used? benefits of using php?

using php is beneficial in four ways

  1. Easy to use 

  2. Cross platForm

  3. Cost benefits

Easy to Use

Code is embedded into HTML. The PHP code is enclosed in special start and end tags that allow you to jump into and out of "PHP mode".

<html>
<head>
<title>Example</title>
</head>
<body>

<?php
echo "Hi, I'm a PHP script!";
?>

</body>
</html>

Cross Platform 

Runs on almost any Web server on several operating systems.
One of the strongest features is the wide range of supported databases Web Servers: Apache, Microsoft IIS, Caudium, Netscape Enterprise Server

Operating Systems: 

UNIX (HP-UX,OpenBSD,Solaris,Linux), Mac OSX, Windows NT/98/2000/XP/2003

  Supported Databases: 

Adabas D, dBase,Empress,
FilePro (read-only), Hyperwave,IBM DB2, Informix, Ingres, InterBase, FrontBase, mSQL, Direct MS-SQL, MySQL, ODBC, Oracle (OCI7 and OCI8), Ovrimos, PostgreSQL, SQLite, Solid, Sybase, Velocis,Unix dbm

Cost Benefits

PHP is free. 

Open source code means that the entire PHP community will contribute towards bug fixes. There are several add-on technologies (libraries) for PHP that are also free.

software = free
platform=free
Development Tools=free phpcoder jeditor

0 comments:

what is php history of php and why php is used

what is php history of php and why php is used 

what is php

PHP == ‘Hypertext Preprocessor’
Open-source, server-side scripting language like ASP and JSP
PHP scripts are executed on the server
PHP Used to generate dynamic web-pages
PHP scripts reside between reserved PHP tags
This allows the programmer to embed PHP scripts within HTML pages
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is free to download and use
Interpreted language, scripts are parsed at run-time rather than compiled beforehand
Source-code not visible by client
‘View Source’ in browsers does not display the PHP code Various
built-in functions allow for fast development
PHP Files

PHP files can contain text, HTML tags and scripts
PHP files are returned to the browser as plain HTML 
PHP files have a file extension of ".php", ".php3", or ".phtml"


Brief History of PHP

PHP (PHP: Hypertext Preprocessor)

 was created by Rasmus Lerdorf in 1994.
It was initially
developed for HTTP usage logging and server-side form generation in Unix.

PHP 2 (1995) 

transformed the language into a Server-side embedded scripting language.
Added database support, file uploads, variables, arrays, recursive functions, conditionals,
iteration, regular expressions, etc.

PHP 3 (1998) 

added support for ODBC data sources, multiple platform support,
email protocols (SNMP,IMAP), and new parser written by Zeev Suraski and Andi Gutmans

. PHP 4 (2000) 

became an independent component of the web server for added efficiency.
The parser was renamed the Zend Engine. Many security features were added.

PHP 5 (2004)

 adds Zend Engine II with object oriented programming,
robust XML support using the libxml2 library,
SOAP extension for interoperability with Web Services, SQLite has been bundled with PHP


Why we use PHP

PHP runs on different platforms (Windows, Linux, Unix, etc.)
 PHP is compatible with almost all servers used today (Apache, IIS, etc.)
 PHP is FREE to download from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side

 Where to Start? 


To get access to a web server with PHP support, you can: Install Apache (or IIS) on your own server, install PHP, and MySQL Or find a web hosting plan with PHP and MySQL support
Easy to Use Code is embedded into HTML. The PHP code is enclosed in special start and end tags that allow you to jump into and out of "PHP mode".   

Easy to Use

Code is embedded into HTML. The PHP code is enclosed in special start and end tags that allow you to jump into and out of "PHP mode".

<html>
<head>
<title>Example</title>
</head>
<body>

<?php
echo "Hi, I'm a PHP script!";
?>

</body>
</html>


Cross Platform 

Runs on almost any Web server on several operating systems.
One of the strongest features is the wide range of supported databases Web Servers: Apache, Microsoft IIS, Caudium, Netscape Enterprise Server

Operating Systems: 

UNIX (HP-UX,OpenBSD,Solaris,Linux), Mac OSX, Windows NT/98/2000/XP/2003

  Supported Databases: 

Adabas D, dBase,Empress,
FilePro (read-only), Hyperwave,IBM DB2, Informix, Ingres, InterBase, FrontBase, mSQL, Direct MS-SQL, MySQL, ODBC, Oracle (OCI7 and OCI8), Ovrimos, PostgreSQL, SQLite, Solid, Sybase, Velocis,Unix dbm

1 comments:

learn Wordpress in urdu/hindi free video tutorials

after completing video in php .i will prepare some  video on wordpress.
wordpress is easy to management CMS (content management system).
before moving i will teach you basics of html and php (i am little busy now and due to some reason could not prepare all video sorry for that)
.let have an intro on wordpress
so

what is wordpress

wordpress is a power full tool for web designing and developing for small business .its more then CMS its very powerful and 30-35% websites are using wordpress .because it not only blogging tool but contains much more.

Plugins and widgets

one thing about wordpress that makes it more and more powerful  is its availability  of thousond of plugin and wedgets etc
if you want to start building website you will not face any problem of coding and building it from scratch.
you ,there are plugins available and you just have to use them.
you can also make your own plugins and widget but you will find every thing there.
Themes
themes are the most important thing in wordpress it is not just layout and css but much more.
their are dozen of theme available some are free and some premium .
like
portfolio theme
job theme
clasified theme
eCommerce 
and many other




i will do more work for you and upload new video about wordpress 

Stay connected comment subcribe .....you know how to learn!

1 comments:

get started with php tutorials

how to get started with php



you want build awesome websites with php!!!
thats great lets start with me.............
i will guide you to learn how to work with php

check my all videos on php here

software package we need for php and web development

first download wampserver which contain all in one package :
  • php
  • mySql
  • phpMyAdmin
using wampserver you dont need to setup all these separately;
after installing wampserver open your browser and type

127.0.0.1
*Note:if it does not work close any open software like ..skype,teamweaver

you will see a webpage that contain information about php ,link of phpmyadmin .
in phpMyAdmin you can mange you databases;


to learn step by step watch all my videos here


0 comments:

switch statement in php urdu

how to use switch statement instead of "if else"
easy php tutorials in urdu
video tutorials

switch statement

 this is simple statement in programing :
example:

like you go to some market and you want to buy Fruit
rates are
apple  120/kg
mango 80/kg
banana 90/kg
orange  150/kg
so these are rates of fruit:ok so will decide which one you want to buy!!!

in programming i will write this in code
MONEY is what you have in your pocket !!!
you can change variable $money value to see the case affects

[code]
 <?php

$money =120; //this is a variable of MONEY like you have 120 rupees

switch($money)

{
case '120':echo "you want to buy apple";
break;
case '90':echo "you want to buy banana";
break;
case '80':echo "you want to buy mango";
break;
case '150':echo "you want to buy orange";
break;

}
?>


[code]

0 comments:

WHILE LOOP IN PHP URDU

How to use while loop in php:
very easy to use while loop in php
php video tutorials in urdu

while loop in php 

you will use while loop to do some work continuously until some condition comes
example:
suppose you have 10 rupees and you are happy with this  money.
$r=10;

you go to some shop.pay 1 rupee to buy something..
now you have 9 rupee left.

buy some other 1 rupee
now you have 8 rupee
.
.
.
at the end you will have 0 rupee . and now you can not buy anything more.. so this is the condition of while loop that when $r==0 you must leave the shop if not continue  ......


[code]

<?php

$r=10; //you have 10 rupees

while ($r!=0)  // $r is not zero then go inside
{

echo "you have ".$r." rupee left";
echo "...buy something<br/> "; //<br/> use to new line

$r--; // minus one value from it like $r=$r- 1;
}

 echo "now you are out of while loop because r =0 now"

?>


[/code]

0 comments:

Get started with android urdu

coming soon.......................................

0 comments:

object oriented paradigm lecture oop ppt free download

object oriented paradigm click here to download
object oriented paradigm lecture free download
object oriented c++ paradigm lecture free download

click here to download object oriented c++ paradigm lecture

0 comments:

introduction to c++ programming fundamenta

c++I N T R O D U C T I O N
Computer based systems make a way into every field all over the world. Computer programs are serving
every sphere of life from calculating simple utility bills and payrolls to automated cruise controls, power
plants and medical diagnostic systems. This course focuses on efficient problem solving by using
computers. The students will be familiarized with the basic structured programming skills. Initially we will
learn how to design and represent solutions/algorithms in pseudo-code then we will learn how to
implement our solutions in C++. The objectives of this course are
• To introduce students to the basic concepts of computer programming.
• The focus of the course will be on general programming principles/techniques
C O U R S E C O N T E N T S
Week Topics
 Introduction to the course and course objectives, Algorithm

 Pseudo-code as a design tool and Practice Sessions
Flowchart as a design tool and Practice Sessions

 Introduction to C++ Data types and Variables, Operators

Control Structures (Sequence, Selection and Iteration) in C++

Arrays and their usage

 Functions and Recursion

 Strings. Pointers

 Structures


notes free download

0 comments:

Computers lecture free download

computer fundamental  and advance learning


 with expert guide/notes very good for beginners must study to improve your knowledge about computer

inside computer 


Chapter 1: Computers & You

Chapter 2: The Internet & the World Wide Web
Chapter 2: The Internet & the World Wide Web
Chapter 3: Wired & Wireless Communication
Chapter 4: System Software
Chapter 5: Application Software:
Tools for Productivity
.......
.........
.............

  • computer are your feature
  •  

    0 comments:

    English Tenses ppt download


    Simple Present (Present Simple) 

    Present continuous
    ¢The present perfect simple expresses an action that is still going on or that stopped recently, but has an influence on the present. It puts emphasis on the result.
    ¢Form of Present Perfect
    Use of Present Perfect Progressive 
     

    0 comments: