版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 超市日常运营管理标准流程
- 物业管理计划书
- 小学班主任教师年度工作总结范本
- 一年级练字标准田字格模板
- 教学楼施工组织设计
- 酸奶生产工艺设计与管理方案
- 乒乓球课-正手攻球说课稿
- 中考数学相似三角形复习教案设计
- 小学数学思维训练导学案模板集
- 四年级英语语法重点梳理总结
- 部编版道德与法治三年级下册第九课《学会倾听》第二课时 课件
- 2026福建福州建工福厝置业有限责任公司第一批招聘22人笔试参考题库及答案解析
- 2025年《中华人民共和国公司法》知识竞赛试卷及答案
- 2026年一级注册建筑师《建筑材料与构造》模拟考试题库有答案详解
- 2026年宁都技师学院招聘编外教师44人笔试参考题库及答案解析
- 2026年安徽省合肥市高三二模英语试题(含答案和音频)
- 2026年录音摄像员通关试题库附答案详解(能力提升)
- 2025年河北省地级市联考遴选笔试真题解析附答案
- 2026科技日报社招聘应届高校毕业生7人考试备考试题及答案解析
- 广西能汇投资集团有限公司招聘笔试题库2026
- 监理安全管理制度和预案(3篇)
评论
0/150
提交评论