Introduction to PHP.ppt_第1页
Introduction to PHP.ppt_第2页
Introduction to PHP.ppt_第3页
Introduction to PHP.ppt_第4页
Introduction to PHP.ppt_第5页
已阅读5页,还剩28页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、A. Chaubal,1,Introduction to PHP,Amrish V. Chaubal Data ,A. Chaubal,8,PHP Constants,.values that never changes Constants are defined in PHP by using the define() function. For e.g. define(“NCST”, “National Centre for Software Technology”) defined() function says whether the constant exists or not.,A

2、. Chaubal,9,PHP Variables,The variables in PHP are declared by appending the $ sign to the variable name. For e.g $company = “NCST”; $sum = 10.0; variables data type is changed by the value that is assigned to the variable. Type casting allows to change the data type explicitly.,A. Chaubal,10,PHP Va

3、riables (cont.),Rich set of functions for working with variable. For e.g gettype, settype, isset, unset, is_int, intval etc etc,A. Chaubal,11,PHP Operators,All the operators such as arithmetic, assignment, Comparison, and logical operators are similar to the operators in C and C+. In PHP the string

4、concatenation operator is denoted by . For e.g. $name = “My name is”.$myname;,A. Chaubal,12,PHP Statements,IF statement if () /php code goes here else /php code goes here Alternative Syntax if() : /html code goes here else : /html code goes here endif;,A. Chaubal,13,PHP Statements (cont.),For loop f

5、or($i=0;$i 10;$+i) echo(“the value is :”. $i); Alternative Syntax for($i=0;$i 10;$+i) : / html code goes here endfor; While loop Do-While loop,A. Chaubal,14,Functions,Function declaration in PHP function my_func() /do something in the function for e.g. function sayHello() echo(“hello amrish”); ,A. C

6、haubal,15,Functions (cont.),Assigning functions to the variables for e.g $hello = “my_func”; to invoke the function my_func() through the variable $hello( ); When an argument is to be passed by reference, an ampersand (,A. Chaubal,16,Arrays,.contains value set each element has a value, data stored i

7、n the element. And has a key by which the element can be referred to.,A. Chaubal,17,Initializing Arrays,No of ways to initialize the array. For e.g. $ncststaff = “amrish”; $ncststaff = “murali”; $ncststaff = “narayan”; $ncststaff123 = “amrish”; $ncststaff122 = “murali”; $ncststaff121 = “narayan”; $n

8、cststaff = array (“amrish”, “murali”, “narayan”); to change the indices of the array use = operator.,A. Chaubal,18,Accessing the Array Elements,The elements in the array can be accessed by using the list and each constructs for e.g while(list($key,$value) = each(countries) echo(“$valuen”); current()

9、 gives the current value being accessed. key() gives the index of the current element that is being accessed. prev() gives the previous element. next() gives the next element.,A. Chaubal,19,Accessing the Array Elements (cont.),Array_walk(,) function_name is the function that is written for every mem

10、ber of an array. For e.g $ncststaff = array (“amrish”, “murali”, “narayan”); array_walk ($ncststaff, printstaff); / function to print each element of the array function printstaff($names) echo “$namesn”; ,A. Chaubal,20,Arrays (cont.),$ncststaff = array (“dake” = array(“amrish”, “lakshana”, “venkat”)

11、, “spc” = array(“narayan”, “murali”,“prasad”); creates a two dimensional array. Sorting Functions sort() : sorts the elements in the numeric and alphabetical order. rsort() : sorts the elements in the reverse order. asort() : sorts the elements in the array without changing the indices. ksort() : so

12、rts the arrays by key.,A. Chaubal,21,Classes,Class is a template of an object and includes the properties and methods that describe an object and behavior. Class in PHP is defined using class statement.,A. Chaubal,22,Classes (cont.),For e.g companyname = $cname; function getnames($idcode) /return th

13、e name of the employee for the required idcode ?,A. Chaubal,23,PHP Richness,PHP comes with myriad of options i.e. supports several APIs and interfaces to other programming tools such as Database connectivity. LDAP XML Mail protocols such as IMAP, SMTP Image functions etc.,A. Chaubal,24,Support for R

14、egular Expressions,Not pretty things to look at and work with. E.g. .+.+.+$ PHP takes over the headache from the programmers for explicitly coding for pattern matching. Functions: ereg() and eregi() ereg_replace() OCIFetchInto; OCIFetchStatement OCIExecute OCIFreeStatement,A. Chaubal,30,LDAP Support in PHP,PHP provides LDAP APIs that allows the programmers to create LDAP clients; by providing transparent access to backend LDAP directory servers. For e.g. Web based e-mail client. Telephone Directory.,A. Chaubal,31,XML Support in PHP,PHP supports a set of functions that c

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论