learn php lacture1

55
PHP & Framework Name:-Adarsh Bhatt Contact:[email protected] 9408374479

Upload: adarsh-bhatt

Post on 14-Nov-2014

110 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

2. Index:- Overview of Open Source Software. Widely Used Open Source Software. Difference between Open Source Software and Close Source Software. Pros and Cons of OSS. Background Information of PHP. Using variables operators & expressions Conditional Statements : if statement switch statement Looping Statements: for loop while loop do..while loop foreach loop Functions & Arrays in PHP PHP functions Creating arrays Regular Expressions 3. PHP and Database Storage Types PHP with MySQL. Deal with Database. Manipulation with tables using PHP. Include(),include_once(). Require(),require_once(). Working with User Data and Error Handling. Cookie Session Error Handling Types of error Object Oriented Programming with PHP. Class, Constructor, Destructure Inheritance Magic Methods. Overview of PHP Framework. Popular PHP Framework. WordPpress, Magento, Opencart, Drupal, Zoomla etc. 4. Overview of Open Source. Open-source software (OSS) is computer software that is available in source code form: the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, improve and at times also to distribute the software. Open Source is a certification standard issued by the Open Source Initiative (OSI) that indicates that the source code of a computer program is made available free of charge to the general public. For an Open Source Software to be an "OSI Certified" a product must meet the following criteria: The author or holder of the license of the source code cannot collect royalties on the distribution of the program. The distributed program must make the source code accessible to the user. The author must allow modifications and derivations of the work under the program's original name. 5. Widely used open source products Linux Kernel (Operating System) Apache (Web Server) GNOME, KDE (Desktop Environment) MySQL (Database emphasizing speed) Postgre SQL ( Database emphasizing functionality) PHP(Server-side scripting) Open Office.org ( multi platform and multi lingual office suite ) Filezilla (fast & reliable FTP client) Pant.net(Free image editing software) 6. Open Source Software vs Close Source Software Term Open Source Closed Source Cost Open source software may be free. If you have in- house capability for implementation, training then it is the best option. Otherwise you need to pay for it. Open source software requires a certain level of technical expertise in order to manage content. Open source software providers are increasingly charging for add-ons, additional services and integration. The cost of proprietary software will vary from a few thousand to a few hundred thousand dollars, depending on the complexity of the system required. This cost is made up of a base fee for software, integration and services and annual licensing/support fees. 7. Term Open Source Closed Source Innovation Open source software enables innovation by providing users with the freedom and flexibility to adapt the software to suit, without restriction. Proprietary software providers do not allow users to view or alter the source code. While this may be viewed as a disadvantage to some, it ensures the security and reliability of the software. Usability It is developer-centric. Requires system administration expertise. No availability of the proper documentation of the system is available. Proprietary software generally employs expert usability testing, and as the software is normally aimed at a more targeted audience 8. Term Open Source Closed Source Services & Support Service is one of the key issues regarding open source software. Open source software relies on its online community network to deliver support via forums and blogs. These communities cannot guarantee the high level of responsive service and support proprietary software can offer. Proprietary software providers offer ongoing support to users, a key selling point for users without technical expertise. Service is one of the main reasons users choose proprietary software, many proprietary software providers compete on service , increasing the bargaining power of buyers and thereby increasing customer service levels among providers. 9. Term Open Source Closed Source Security Open source software is not developed in a controlled environment. While development they often have a oconcentrated dev. team, oindividuals all over the world who may not work on the software for the duration of its developing lifetime. This lack of continuity and common direction can lead to barriers to effective communication surrounding the software. Proprietary software is viewed as more secure because it is developed in a controlled environment by a concentrated team with a common direction. 10. Pros and Cons of OSS Pros of OSS:- Helped to produce reliable, high quality software quickly and inexpensively. thousands of independent programmers testing and fixing bugs of the software. From a developers point of view, open source technologies provide a platform on which to build custom solutions. 11. Cons of OSS In terms of security, open source may allow hackers to know about the weaknesses or loopholes of the software more easily than closed-source software. open source development process may not be well defined and the stages in the development process, such as system testing and documentation may be ignored. It is also difficult to design a commercially sound business model around the open source paradigm. Anyone can develop competing product because its Open Source. Almost everything in open source is viewable by other developers. If a developer makes a major mistake, it can become public information and 12. Background Information of PHPPHP stands for Hypertext Preprocessor. It is widely used Open source, general purpose scripting language for web development & can be embedded into HTML. Hypertext preprocessor is an interpreter of PHP code created to run successfully on web servers.The interpreter processes PHP code spec invoked by web server & finally dispatches HTML code to a browser. PHP is a server-side scripting language which means that PHP scripts or programs usually run on the web server. PHP Script is processed by PHP Engine each time when it runs. PHP Syntax is based on C. So it is easy for C Programmer to learn & work in PHP. PHP was created by Rasmus Lerdorf in 1994, a developer of PERL/CGI Script. Version 1 : (1994) PHP started out with the set of simple tools coded in C language to replace Perl script and it was used on his Personal Home Page (so acronym - PHP). 13. Version 2 : (1995) First popular version of PHP. Version 3 : (1998) Developers were able to write their own modules for language, adding functionality to its core. Version 4 : (2000) Important change made to PHP 4 was switching to Zend Engine, created by Zend company found by Zeev Suraski and Andi Gutmans. PHP started running on: Apache Web Server Microsofts IIS Zeus AOLServer & many more Web Servers. Version 5 (2004) It focused on language maturity & offered a lots of new functionalities that had been missing in previous versions. Cont 14. Cont PHP 6 :- Currently available as a developer snapshot which can be downloaded and tried out. It is planning to offer the following :- Improved Unicode Support Namespaces, SOAP, XML. Benefits of running PHP As a Server Side Script PHP Script is always invisible to client browser, as Web Server sends only output of PHP Script to client browser, not script only. PHP Scripts are browser neutral. Drawbacks in running PHP as a Server Side Script PHP consumes lots of web server resources because everything is executed on Web Server. With many concurrent requests & large complex scripts, the server might not be able to respond smoothly. PHP 5.5.7 is a latest version release on 12th december,2013. PHP 5.6.0 alpha1 released on 23rd Jan,2014 but it is in development preview mode. 15. What is a PHP file?PHP File is an ASCII file created using any editor like Notepad, Dreamviewer, etc. and stored on HDD. The file contains mix of HTML & PHP. PHP files may contain text, HTML tags & scripts. After PHP files is processed, output is returned as plain HTML. PHP files usually have .PHP extension. PHP runs on different OS platforms seamlessly, being interpreted scripting language. PHP is compatible with almost all Web Servers. PHP is free to download from official PHP Resource. PHP is easy to learn & runs efficiently on any compatible Web Server. 16. Internal Structure of PHP Database Webpage w e b s e r v e r Function Modules InterfaceWeb Server Interface Runtime Compiler Zend Engine Executor Web Server Software Modules php MySQL Oracle ODBC XML PDO ... 17. Variables are identifiers which point to memory location in which data are stored. Variables in PHP are weakly/loosely typed which means when a variable is being defined their data type is not declared prior to use. Variables can change its type depending on value being assigned as often needed. Variables 18. Variable name should begin with dollar sign. First character after dollar sign should be letter or an underscore. Remaining characters in a variable name can be letters, characters, or underscore without any fixed limit. Following characters are not allowed in variable name :- *, +, #, @, -,&,. Variables in PHP are case-sensitive. Naming Rules for variables 19. As it allows to convert variables data-type automatically depending on the content in the variable. It is beneficial as it makes variable very flexible & same variable can be used at several different situations. It is disadvantageous as , if you pass around data accidentally of wrong type it wont inform you about it. To know variable datatype use gettype($var) function.e.g PHP is loosely-typed language 20. DataType: - PHP has several different types of variables. All holds specific class/type of information. PHP has 8 basic data types which are categorized into 3 categories :- 1. Scalar Datatype 2. Compound Datatype 3. Special Datatype 21. Scalar Data Type:-Scalar data means data that contains only a single value. Data type Description Integer -Stores whole numbers either +ve or ve. -If value assigned is out of the range it is converted to float. Float - Store floating point numbers as well as higher integers. String - Stores sequence of characters terminated by NULL. Boolean -It holds true or false. -Internally it holds integer value - 0 for false - rest values for true. 22. Compound Data Type Compound data is data that can contain more than one variable. Data type Description Array -Ordered map -It holds multiple values. Object -They have multiple values within it. -They have their own functions for accessing and/ or manipulating its data. 23. Special Data typePHP supports two special data types which have a specific meaning. Data types Description Resource Contains a reference to an external resource, such as file or database. It can be used in same manner as we use another variables but only difference is it should be freed up when not required. Null Contains null as a value. Explicitly do not contain any value. 24. Conditional Statements if statement switch statement goto statement 25. If statement Simple if if(test-expr) { True part } statement If...else statement if(test-expr) { True part } else { False part } Nested if statement if(test-exp 1) { if(test-exp 2) { true 1 & 2 } else { false 2 } } else { false part all } 26. else if ladder :- if(test-exp 1) statement -1; else if(test-exp 2) statement 2; else if(test-exp 3) statement 3; . . . else false statement switch statement :- switch(ch) { case value1: statement 1;break; case value2: statement 2;break; case value3: statement 3; break; . . . default : statement-false; break; } Case value can be of any data type or even any condition. We can use break and continue interchangeable. Default can be placed anywhere in switch. 27. goto statement The goto operator can be used to jump to another section in the program. The target point is specified by a label followed by a colon, and the instruction is given as goto followed by the desired target label. The target label must be within the same file and context, meaning that you cannot jump out of a function or method, nor can you jump into one. You also cannot jump into any sort of loop or switch structure. 28. goto statement Forward Jump :- Example :