Skip to main content

Posts

Showing posts from February, 2015

White space in PHP

White space in PHP : <html> <head> <title>My First PHP Page</title> </head> <body> <?php echo "Hello World!";                  /*As with HTML, whitespace is ignored between PHP statements.                                       This means it is OK to have one line of PHP code, then 20 lines of blank space                                       before the next line of PHP code. You can also press tab to indent your code and                                       the PHP interpreter will ignore those spaces as well. like from line 9 to line                                       15 its whitespace but php does not consider it as whitespace*/ echo "Hello World!"; ?> </body> </html>

First page of php

<html> <head> <title>My First PHP Page</title> </head> <body> <?php echo "Hello World!";  /* echo is used for the output statement so here the string [my first page of php will be                   will be displayed. The string should be in the " " for displying   */ ?> </body> </html>

Syntax of Php

PHP SYNTAX: Before we talk about PHP's syntax, let us first define what syntax is referring to. Syntax - The rules that must be followed to write properly structured code. PHP's syntax and semantics are similar to most other programming languages C, Java, Perl) with the addition that all PHP code is contained with a tag of sorts. All PHP code must be contained within the following: <?php All stuff will be in the between of this       ?>

Introduction to PHP

Introduction to php: PHP stands for Hypertext Preprocessor. Other Names : Personal Home Page, Professional Home Page Is a server side scripting language. Capable of generating the HTML pages HTML generates the web page with the static text and images. However the need evolved for dynamic web based application, mostly involving database usage. Why world need php: There are number of server side scripting available like ASP, SSJS, JSP….. PHP involves simplicity in scripting (..generally using the database) platform independence. PHP is primarily designed for web applications well optimized for the response times needed for web applications Is an open source. Data types of php: Three basic data types Integer Double String More data types Array Object PHP is an untyped language variables type can change on the fly.

Prefix and Post fix

Prefix and Post fix #include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; // Prefix increment and post fix increment main() { int a=3,b=4; cout<<".........Prefix increment.........."<<endl; cout<<"previous value of b="<<b<<endl;   // as we know what is happening here  cout<<++b<<"=due to prefix increment"<<endl;          /*as form the name prefix increment its increment value before using it in the program                       like b=4 so ++b mean increment a value before its get use */ cout<<".........Post fix increment.........."<<endl; cout<<"previous value of a="<<endl;  // as we know what is happening here cout<<"value of a is =\t"<<a++<<"\\t although ++ sign is there"<<endl;  c

Temperature Convertor

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { float c,f ;   // as i discussed earlier float is used for floating values like value is decimel so two variable are take  cout<<"Enter the temperature in Fahrenheit  ? :"; // its just comment whatever you want can add here within "" after cout  cin>>f;                                         // giving a value which will convert the program to Fahrenheit c= (f-32)*5.0/9.0;      // it is the formula to convert to fahrenheit cout<<"Temperature in celsius = "<<c; // here its show the value save in the c throgh the formula   } /* Here is your temperature converter to farhrenheid is ready */

Age Calculator

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { int age;           // age variable with datatype int long int age_month; /* long is also a datatype but it can hold more bigger data then int                      so variable age_month with datatype long */ char name[50];     // char is datatype with variable name name it can only hold character like " naveed" cout<<"Enter name of person:"<<endl; // will output Comment "enter the name of person cin>>name;                   //here is input object through which you can enter the name of person cout<<"enter the age of person in year:"<<endl; // here its output the comment "enter the age " cin>> age;                             // here is the input function which input the age form the user     age_month=a

Cin function

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { int a,b; // two variable are taken as a and b cout<<"enter a value "<<endl; /* as you know cout is used to print out your comment enclosed in " " this                              endl is used for next line */ cin>>a;        /* here is new thing "cin" it is used to input values on running time of program*/ cout<<"enter a value "<<endl; /* as you know cout is used to print out your comment enclosed in " " this                              endl is used for next line */ cin>>b;        /* here is new thing "cin" it is used to input values on running time of program*/ }

Arithm

/* c++ is world popular language you can do every thing with the help of this but after learning it today  lecture is on making calcultor but its mini hahahha c++ have some Arthmetic operator  like + ,- ,*, /, % today i will teach you how to use these operator in c++*/ #include<iostream> #include<conio.h> using namespace std; main() { int r;  // declaring variable of data type int r=2;    // assigning values to that variable int b;  //declaring another varaible ; b=4;    // assigning value to that variable int sum; // declaring another varaible to hold the sum of the two variables sum=r+b;  // here i am adding these two variables cout<<sum;  //here is output of sum variable } /* CONCEPT: you are aware of assigning values to variable but here is another concept  on line 21 i declare int sum on line 23 the addition of both r and b are assign  to the sum and at the end sum is out put  so here a single variable is holding a

Assign Values to Variables

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main()                 // it is the start of you your programe its means form here you will                        // start the coding . .  comouter only understand this main                       { int a=3,b=5;      /* Now what is  int a=3, b=5; as you are now full aware of (int)                   and (variable) but this  is some thing difficult. .  wait a minute                   its not difficult.*/ cout<<a<<endl; cout<<b<<endl;      /* as i discussed before that cout is use for out put statement                        but what do you think what will be output. . */ } /* CONCEPT: here its called assignment of  integers to variables like a=3 mean 3 is assign to a so if we cout (a) it will give us 3 same for the b.. .  todays lecture is very easy so enjoy upto

Variable And INT

#include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main() { int a;                           /* what is (int) here and what is (a) here                    the two question which was in mind of me                    when i was in first semester*/                   } /* Here there are two thing 2) int 1) a: is basically a Variable which represent a storage or memory in computer like if we define (int a) then a memory is located in computer to store the value of a it can be changed during execution of program but i will define it later 2) int 2) INT : int basically specifies the type of data that can be stord in it Each variable is declared by its types like i)int =  can hold integers like 22 is an integer so it will be good to store it in (int) ii) float= can store float values like 22.5 22.1 or every float

basic syntax of c++

Basic syntax of c++  #include<iostream>     // it is  a library used for display #include<conio.h>      // its is also a library used for input output statement using namespace std; main()                 // it is the start of you your program its means form here you will                        // start the coding . .  computer only understand this main                       {                      // starting your program  from starting cout<<"here is my first program in c++ "; // cout mean show me . . . << mean the thing infront of this <<                                          // " is used to give a simple string and you should put this after                                          // finishing your line . . . . and this ; is use to finish your one                                          // statement. } /* when you are going to save your this program you should give his extension cpp */ put this program