AN INTRODUCTION to PHP Create Dynamic Web Applications

Total Page:16

File Type:pdf, Size:1020Kb

AN INTRODUCTION to PHP Create Dynamic Web Applications 1. What Is PHP Programming language created to enable web developers to quickly AN INTRODUCTION TO PHP create dynamic web applications PHP stands for "PHP: hypertext preprocessor" 4LDQJ;X DQG<XDQOLQJ5HQ Html-embedded programming language syntactically similar to C, Perl, and java 2. What a PHP Script Looks Like PHP preprocessor execute all code <HTML> between <?php and ?> tag and return <HEAD> results as text <TITLE>A Simple PHP Example</TITLE> </HEAD> <HTML> <BODY> <HEAD> <?php echo "Hello from PHP!“ ?> <TITLE>A Simple PHP Example</TITLE> </BODY> </HEAD> </HTML> <BODY> Hello from PHP!</BODY> </HTML> 3. The Syntax of the Language Constant similar to C, Perl, and Java Predefined constant Type HTTP_HOST, HTTP_USER_AGENT ... floating-point, integer, string, array, and object Define your own constant Variable <?php $i=5; $f=1.2; define ("aString", “xxxxxx"); $s="This is a simple string."; define("aNumber", 1); $y[0] = "red"; $y[1] = "green"; print(aNumber . "constant with value $color["blue"] = "#0000FF"; of" . aString . "<br>"); $color["green"] = "#00FF00"; ?> Functions OO/Classes Arguments can be passed by value support class creation with syntax similar to C++ and by reference Constructor exist, no destructor <?php function ReturnSum(&$a, $b) { Requires $this variable within classes $c = $a + $b; to refer to member variables and return $c; methods } Single inheritance, but not multiple ?> <?php function AddItem($aName, $aV, $aQty){ $this->item[$aName]["Q"] = $aQty; $this->item[$aName]["V"] = $aV; class ShoppingBasket { $this->value += $aV * $aQty; var $item; return true; var $value; } ... function ShoppingBasket ($initValue) { } $this->value = $initValue; $aBasket = new ShoppingBasket(3.5); } $aBasket->AddItem("Rose", 10, 2); $aBasket->PrintBasket(); ?> Pattern Matching 4. Forms and Cookies PHP supports two types of pattern- Forms matching functions: <form action = "post1.phtml" method = Perl-compatible regular expression "post"> ...... </form> functions, function names all start with preg_ string Form values stored in PHP-Generated variables, e.g, HTTP_POST_VARS POSIX-style functions: ereg(), ergi(), ereg_replace(), Form data validation eregi_replace(), split() regular expression functions in PHP programs validator class 5. Working With File Objects provide C-like functions for One of beautiful thing about PHP is its managing file objects open-source.http://www.thewebmasters.net provides great open-source classes and source modules. For data validation, fopen(),fclose(), fput(), popen() Validator class provides an array of fsockopen("208.129.36.164", 17), functions, e.g, is_email(), is_url(), is_phone() upload files whose names are submitted in form data, i.e., it Cookies can read a file of client and setcookie(), HTTP_COOKIE_VARS. save it in server side. 6. Working With Databases An example using MySQL support <?php Adabas D, dBase, Empress, FilePro, $aLink = mysql_connect(“xx.xx.com", Informix, InterBase, mSQL, MySQL, "user", "passwd" ); Oracle, postgreSQL, Solid, Sybase, Velocis, Unix dbm, Microsoft SQL if( !empty($aLink) ) { Server, ODBC if( mysql_select_db( "mydb", $aLink ) == True ) { With inclusion of ODBC, PHP probably $Qry = "select * from E"; can be used to access any available $R = mysql_query($Qry, $aLink); DBMS. if($R == True ) { 7. Debugging while($aRow = assert() mysql_fetch_array($R)){ $aFName = $aRow["first"]; assert('is_array($anArray )'); $aPos = $aRow["position"]; print( "$aFName, $aPos <br>" ); error_log() } error_log(“Error here!", 0); } error_log(“Err!",3,"/tmp/error.log"); } error_log(“Error!", 1, “[email protected]", } "From: [email protected]\r\n"); ?> write your own error handler 8. Code Reuse Reusing code is significant function myErrorHandler( $aErrorNo, consideration in any programming $aErrorStr, $aFile, $aLine, $aContext) language { } PHP provides means for including set_error_handler("myErrorHandler"); external files and creating OO classes, it facilitates code reuse. With a little bit effort, you can reuse code written in C/C++, Java, COM, and PHP 9. Cool PHP support template system Send Non_HTML files to browser For E-Commerce, PHP provides full scripting language that can be interfaces to several payment used for any programming task processing systems including CyberCash,VeriSign, and CCVS support The Web Distributed Data Exchange (WDDX) support sockets and network protocols , developing network monitoring utility in PHP is straightforward syntax and structure resemble C with 10.Why Better than Its Alternatives complexity(e.g. memory management, pointers, and strong typing) taken out. PHP is free support direct access to Java objects on any system with Java Virtual Machine Open Source software available, as well as Distributed COM on download complete source code Windows. broad platform support modifiable. designed to allow extension of functionality. It's coded in C and provides a well_defined API Enforce cleaner separation of 11.Conclusion layout and application logic PHP is full-fledged programming language that will enable you to Abundant Connectivity create Web applications with all functionality you need support most current Internet standards: IMAP, FTP, POP, XML, WDDX, LDAP, NIS, and SNMP can be compiled as stand-alone script interpreter, and handle simple system administration tasks .
Recommended publications
  • System Integration in Web 2.0 Environment
    Masaryk university, Faculty of Informatics Ph.D. Thesis System Integration in Web 2.0 Environment Pavel Drášil Supervisor: doc. RNDr. Tomáš Pitner, Ph.D. January 2011 Brno, Czech Republic Except where indicated otherwise, this thesis is my own original work. Pavel Drášil Brno, January 2011 Acknowledgements There are many people who have influenced my life and the path I have chosen in it. They have all, in their own way, made this thesis and the work described herein possible. First of all, I have to thank my supervisor, assoc. prof. Tomáš Pitner. Anytime we met, I received not only a number of valuable advices, but also a great deal of enthusiasm, understanding, appreciation, support and trust. Further, I have to thank my colleague Tomáš Ludík for lots of fruitful discussions and constructive criticism during the last year. Without any doubt, this thesis would not come into existence without the love, unceasing support and patience of the people I hold deepest in my heart – my parents and my beloved girlfriend Míša. I am grateful to them more than I can express. Abstract During the last decade, Service-Oriented Architecture (SOA) concepts have matured into a prominent architectural style for enterprise application development and integration. At the same time, Web 2.0 became a predominant paradigm in the web environment. Even if the ideological, technological and business bases of the two are quite different, significant similarities can still be found. Especially in their view of services as basic building blocks and service composition as a way of creating complex applications. Inspired by this finding, this thesis aims to contribute to the state of the art in designing service-based systems by exploring the possibilities and potential of bridging the SOA and Web 2.0 worlds.
    [Show full text]
  • PHP Credits Configuration
    PHP Version 5.0.1 www.entropy.ch Release 1 System Darwin G4-500.local 7.7.0 Darwin Kernel Version 7.7.0: Sun Nov 7 16:06:51 PST 2004; root:xnu/xnu-517.9.5.obj~1/RELEASE_PPC Power Macintosh Build Date Aug 13 2004 15:03:31 Configure './configure' '--prefix=/usr/local/php5' '--with-config-file-path=/usr/local/php5/lib' '--with-apxs' '- Command -with-iconv' '--with-openssl=/usr' '--with-zlib=/usr' '--with-mysql=/Users/marc/cvs/entropy/php- module/src/mysql-standard-*' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with- xsl=/usr/local/php5' '--with-pdflib=/usr/local/php5' '--with-pgsql=/Users/marc/cvs/entropy/php- module/build/postgresql-build' '--with-gd' '--with-jpeg-dir=/usr/local/php5' '--with-png- dir=/usr/local/php5' '--with-zlib-dir=/usr' '--with-freetype-dir=/usr/local/php5' '--with- t1lib=/usr/local/php5' '--with-imap=../imap-2002d' '--with-imap-ssl=/usr' '--with- gettext=/usr/local/php5' '--with-ming=/Users/marc/cvs/entropy/php-module/build/ming-build' '- -with-ldap' '--with-mime-magic=/usr/local/php5/etc/magic.mime' '--with-iodbc=/usr' '--with- xmlrpc' '--with-expat -dir=/usr/local/php5' '--with-iconv-dir=/usr' '--with-curl=/usr/local/php5' '-- enable-exif' '--enable-wddx' '--enable-soap' '--enable-sqlite-utf8' '--enable-ftp' '--enable- sockets' '--enable-dbx' '--enable-dbase' '--enable-mbstring' '--enable-calendar' '--with- bz2=/usr' '--with-mcrypt=/usr/local/php5' '--with-mhash=/usr/local/php5' '--with- mssql=/usr/local/php5' '--with-fbsql=/Users/marc/cvs/entropy/php-module/build/frontbase- build/Library/FrontBase' Server
    [Show full text]
  • Web Application Development with PHP 4.0 00 9971 FM 6/16/00 7:24 AM Page Ii
    00 9971 FM 6/16/00 7:24 AM Page i Web Application Development with PHP 4.0 00 9971 FM 6/16/00 7:24 AM Page ii Other Books by New Riders Publishing MySQL GTK+/Gnome Application Paul DuBois, 0-7357-0921-1 Development Havoc Pennington, 0-7357-0078-8 A UML Pattern Language Paul Evitts, 1-57870-118-X DCE/RPC over SMB: Samba and Windows NT Domain Internals Constructing Superior Software Luke Leighton, 1-57870-150-3 Paul Clements, 1-57870-147-3 Linux Firewalls Python Essential Reference Robert Ziegler, 0-7357-0900-9 David Beazley, 0-7357-0901-7 Linux Essential Reference KDE Application Development Ed Petron, 0-7357-0852-5 Uwe Thiem, 1-57870-201-1 Linux System Administration Developing Linux Applications with Jim Dennis, M. Carling, et al, GTK+ and GDK 1-556205-934-3 Eric Harlow, 0-7357-0021-4 00 9971 FM 6/16/00 7:24 AM Page iii Web Application Development with PHP 4.0 Tobias Ratschiller Till Gerken With contributions by Zend Technologies, LTD 201 West 103rd Street, Zeev Suraski Indianapolis, Indiana 46290 Andi Gutmans 00 9971 FM 6/16/00 7:24 AM Page iv Web Application Development with PHP 4.0 By:Tobias Ratschiller and Till Gerken Copyright © 2000 by New Riders Publishing Publisher FIRST EDITION: July, 2000 David Dwyer All rights reserved. No part of this book may be reproduced Executive Editor or transmitted in any form or by any means, electronic or Al Valvano mechanical, including photocopying, recording, or by any information storage and retrieval system, without written Managing Editor permission from the publisher, except for the inclusion of Gina Brown brief quotations in a review.
    [Show full text]
  • XML Schema Built-In Data Types Reference
    APPENDIX A ■ ■ ■ XML Schema Built-in Data Types Reference XML Schemas provide a number of built-in data types. You can use these types directly as types or use them as base types to create new and complex data types. The built-in types presented in this appendix are broken down into primitive and derived types and further grouped by area of functionality for easier reference. Type Definition XML Schema data types are built upon relationships where every type definition is either an extension or a restriction to another type definition. This relationship is called the type defi- nition hierarchy. The topmost definition, serving as the root of the hierarchy, is the ur-type definition, named anyType. It is the only definition that does not have a basis in any other type. Using this data type is similar to using ANY within a DTD. It effectively means that the data has no constraints. Take the following element declaration, for example: <xsd:element name="anything" type="xsd:anyType" /> An element based on this declaration can contain any type of data. It can be any of the built-in types as well as any user-derived type. The simple ur-type definition, named anySimpleType, is a special restriction on the ur-type definition. It constrains the anyType definition by limiting data to only the built-in data types, shown in the following sections. For example, the following element declaration defines an element that can be any built-in type but cannot be a complex type, which is sim- ply an element that can contain subelements or attributes, as explained in Chapter 3: <xsd:element name="simplelement" type="xsd:anySimpleType" /> The built-in types are divided into two varieties: primitive types and derived types.
    [Show full text]
  • PHP Version 5.2.14
    PHP information - webtrees http://webtrees.net/webtrees_demo/admin_site_info.php?ac... PHP Version 5.2.14 System Linux wh3.2qikhosting.co.nz 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:54:40 EST 2010 i686 Build Date Aug 12 2010 15:41:50 Configure ' ./configure' ' --build=i686-redhat-linux-gnu' ' --host=i686-redhat-linux-gnu' ' --target=i386-redhat-linux-gnu' ' --program-prefix=' ' Command --prefix=/usr' ' --exec-prefix=/usr' ' --bindir=/usr/bin' ' --sbindir=/usr/sbin' ' --sysconfdir=/etc' ' --datadir=/usr/share' ' --includedir=/usr/include' ' --libdir=/usr/lib' ' --libexecdir=/usr/libexec' ' --localstatedir=/var' ' --sharedstatedir=/usr/com' ' --mandir=/usr/share/man' ' --infodir=/usr/share/info' ' --cache-file=../config.cache' ' --with-libdir=lib' ' --with-config-file-path=/etc' ' --with-config-file-scan-dir=/etc/php.d' ' --disable-debug' ' --with-pic' ' --disable-rpath' ' --without-pear' ' --with-bz2' ' --with- exec-dir=/usr/bin' ' --with-freetype-dir=/usr' ' --with-png-dir=/usr' ' --with-xpm-dir=/usr' ' --enable-gd-native-ttf' ' --with-t1lib=/usr' ' --without-gdbm' ' --with-gettext' ' --with-gmp' ' --with-iconv' ' --with-jpeg-dir=/usr' ' --with-openssl' ' --with-pcre-regex' ' --with-zlib' ' --with-layout=GNU' ' --enable-exif' ' --enable-ftp' ' --enable-magic-quotes' ' --enable-sockets' ' --enable-sysvsem' ' --enable-sysvshm' ' --enable-sysvmsg' ' --with-kerberos' ' --enable-ucd-snmp-hack' ' --enable-shmop' ' --enable-calendar' ' --without-mime-magic' ' --without-sqlite' ' --with-libxml-dir=/usr' ' --with-xml' ' --with-system-tzdata' ' --with-apxs2=/usr/sbin/apxs'
    [Show full text]
  • Restful Or Restless – Current State of Today's Top Web Apis
    RESTful or RESTless – Current State of Today’s Top Web APIs Frederik B¨ulthoff, Maria Maleshkova AIFB, Karlsruhe Institute of Technology (KIT), Germany frederik.buelthoff@student.kit.edu, [email protected] Abstract Recent developments in the world of services on the Web show that both the number of available Web APIs as well as the applications built on top is constantly increasing. This trend is commonly attributed to the wide adoption of the REST architectural principles [1]. Still, the development of Web APIs is rather autonomous and it is up to the providers to decide how to implement, expose and describe the Web APIs. The individual implementations are then commonly documented in textual form as part of a webpage, showing a wide variety in terms of content, structure and level of detail. As a result, client application developers are forced to manually process and interpret the documen- tation. Before we can achieve a higher level of automation and can make any significant improvement to current practices and technolo- gies, we need to reach a deeper understanding of their similarities and differences. Therefore, in this paper we present a thorough analysis of the most popular Web APIs through the examination of their docu- mentation. We provide conclusions about common description forms, output types, usage of API parameters, invocation support, level of reusability, API granularity and authentication details. The collected data builds a solid foundation for identifying deficiencies and can be used as a basis for devising common standards and guidelines for Web API development. arXiv:1902.10514v1 [cs.SE] 20 Feb 2019 1 Introduction Recent developments in the world of services on the Web show that both the number of available Web APIs as well as the applications built on top is constantly increasing1.
    [Show full text]
  • Cyber Hygiene Sample Report
    ASSESSMENT SUMMARY Cyber Hygiene Assessment CYHYNONE NUMBER April 2, 2018 DATE Cyber Hygiene Assessment Sample Organization Contents 1 How To Use This Report 5 1.1 SAMPLE Points of Contact ................................................. 5 2 Report Card 6 3 Executive Summary 7 4 Sub-Organization Summary 10 5 Methodology 11 5.1 Background ........................................................ 11 5.2 Process .......................................................... 11 6 Approximate Host Locations 14 7 Vulnerability Scan Results 15 8 Results Trending 17 9 Conclusion 20 Appendices 21 Appendix A Vulnerability Summary 21 Appendix B Vulnerability Changes Since Last Report 23 B.1 Mitigated Vulnerabilities .................................................. 23 B.2 New Vulnerabilities Detected ................................................ 32 B.3 Re-Detected (Previously-Mitigated) Vulnerabilities ..................................... 32 B.4 Recently-Detected Vulnerabilities ............................................. 36 Appendix C Detailed Findings and Recommended Mitigations by Vulnerability 44 Appendix D Critical and High Vulnerability Mitigations by IP Address 69 2 April 2, 2018 Appendix E False Positive Findings 70 E.1 Expiring Soon False Positive Findings ........................................... 70 E.2 All False Positive Findings ................................................. 70 Appendix F Frequently Asked Questions 71 Appendix G Attachments 74 Appendix H Glossary and Acronyms 75 List of Figures 1 Top Vulnerabilities by Occurrence
    [Show full text]
  • Adobe Coldfusion, Review the Coldfusion Product Editions, System Requirements, and Other High-Level Considerations
    Installing ADOBE® COLDFUSION SFMFBTF Legal notices Legal notices For legal notices, see http://help.adobe.com/en_US/legalnotices/index.html. Last updated 2/17/2016 iii Contents Understanding ColdFusion Server Profiles . .1 Preparing to Install ColdFusion . .2 Installing the Server Configuration . .4 Installing the JEE Configuration . 32 Installing ColdFusion Express . 57 Installing Integrated Technologies . 59 Configuring your System . 65 Troubleshooting installation issues . 74 Last updated 2/17/2016 1 Understanding ColdFusion Server Profiles To develop and deploy ColdFusion applications, you can use one of the multiple server profiles available when you install ColdFusion. The ColdFusion installer allows you to install the ColdFusion Server in the following profiles (modes): 1 Development profile 2 Production profile 3 Production profile (secure) Depending on the type of profile selected during the installation, the server will be automatically configured with the appropriate settings. Choose the right profile in the installer: Last updated 2/17/2016 2 Once you install the Server using a particular profile, you can't change the profile later. The following table shows the difference between the 3 supported Server profiles: Feature Development Profile Production Profile Production Profile (Secure) Support for all types of Yes No No debugging Support for remote inspection Yes No No Support for strict enforcement of No Yes Yes complex passwords Support for remote start/stop Yes No No Support for Weinre and other Yes No No bundled servers (For instance, Node.js) Support for enabling unused Yes No No servlets Support for Secure Profile . No No Yes Depending upon the option selected, a few settings will be pre-configured in the Administrator.
    [Show full text]
  • Using Perl with WDDX Table of Contents
    By icarus This article copyright Melonfire 2000−2002. All rights reserved. Using Perl With WDDX Table of Contents Speaking In Tongues...........................................................................................................................................1 The Big Picture....................................................................................................................................................2 Packet Sniffer......................................................................................................................................................3 Boyz 'N The Hood...............................................................................................................................................6 All Mixed Up.....................................................................................................................................................10 Flying Toasters And Dancing Knives..............................................................................................................14 Different Strokes...............................................................................................................................................17 This Way Out....................................................................................................................................................20 i Speaking In Tongues As a Web developer, you probably already know how frustrating it is to get applications written in different languages to talk nice to
    [Show full text]
  • PHP Optimization Using Hip Hop Virtual Machine Chaitali Tambe, Pramod Pawar, Dashrath Mane Vivekanand Education Society Institute of Technology, Chembur
    International Journal of Advanced Research in Computer Engineering & Technology (IJARCET) Volume 4 Issue 6, June 2015 PHP Optimization Using Hip Hop Virtual Machine Chaitali Tambe, Pramod Pawar, Dashrath Mane Vivekanand education society institute of technology, Chembur Abstract— HipHop compiler is PHP based compiler created facebook.com. PHP applications that were developed by facebook in order to optimize the php code and save using HipHop terminology resulted in increased speed of resources on the facebook server. HPHPc translates the php application. Several drawbacks of standalone php code into executable c++ code. Later facebook realized that applications were eliminated by using HPHPc, one of HPHPc had some snags which included resource consumption and parallel maintenance of HPHP and which was performance. HPHPi. In order to overcome the drawbacks of HPHPc A. Limitation of HPHPc: HipHop virtual machine was developed in 2011 which is a process virtual machine based on just-in-time (JIT) HPHPc did not fully support the PHP language, compilation, serving as an execution engine for PHP and including the create_function() and eval() Hack programming languages. HHVM provides complete constructs. support for the entire PHP language. This paper shows how HHVM is superior to other compilers like PHP, PHP 7 It involved a specific time and resource consuming and how various framework uses HHVM to optimize deployment process that required a bigger than php. In addition the lock-down approach shows the 1 GB binary to be compiled and distributed to behavior of each framework with hhvm and show how many servers in short orders. performance optimization can be obtained for heavy In addition, maintaining HPHPc and HPHPi in websites.
    [Show full text]
  • Web Hosting Comprehensive, Scalable Solutions for Hosting Dynamic Websites, Secure Web Services, and Enterprise Applications
    Web Hosting Comprehensive, scalable solutions for hosting dynamic websites, secure web services, and enterprise applications. Features Mac OS X Server combines the latest open source and standards-based Internet services in a complete, easy-to-use web hosting solution. At the core is Apache, the world’s High-performance Apache web server most popular web server. Performance optimized for Mac OS X Server, Apache provides • Apache 1.3 and 2.01 with HTTP 1.1 support fast, reliable web hosting and an extensible architecture for deploying enterprise Java • Support for virtual hosting, including multiple IP addresses and virtual domains applications and delivering dynamic content and sophisticated web services. Apple’s • Encrypted data transport with support for innovative administrative tools make it possible for organizations of any size to host SSL and TLS protocols websites and deploy powerful web applications quickly, easily, and affordably. • WebDAV support for collaborative content publishing Mac OS X Server takes the complexity out of configuring, hosting, and managing websites. An intuitive administrative interface makes it easy to get started with a static Dynamic content deployment website, while providing advanced capabilities for professional webmasters responsible • Extensible Apache module architecture for deploying sophisticated services. Tools for serving dynamic content, CGI scripting, • In-line HTML scripting using server-side enterprise applications, database integration, and blog publishing and syndication are includes (SSIs) and PHP already built in, as is OpenSSL for encrypted data transport. Mac OS X Server combines • Support for the UNIX CGI 1.1 standard and all of these web technologies with innovative management tools for superior ease of scripting using Perl, Ruby, and Python use.
    [Show full text]
  • Wikipedia Data Analysis
    Wikipedia data analysis. Introduction and practical examples Felipe Ortega June 29, 2012 Abstract This document offers a gentle and accessible introduction to conduct quantitative analysis with Wikipedia data. The large size of many Wikipedia communities, the fact that (for many languages) the already account for more than a decade of activity and the precise level of detail of records accounting for this activity represent an unparalleled opportunity for researchers to conduct interesting studies for a wide variety of scientific disciplines. The focus of this introductory guide is on data retrieval and data preparation. Many re- search works have explained in detail numerous examples of Wikipedia data analysis, includ- ing numerical and graphical results. However, in many cases very little attention is paid to explain the data sources that were used in these studies, how these data were prepared before the analysis and additional information that is also available to extend the analysis in future studies. This is rather unfortunate since, in general, data retrieval and data preparation usu- ally consumes no less than 75% of the whole time devoted to quantitative analysis, specially in very large datasets. As a result, the main goal of this document is to fill in this gap, providing detailed de- scriptions of available data sources in Wikipedia, and practical methods and tools to prepare these data for the analysis. This is the focus of the first part, dealing with data retrieval and preparation. It also presents an overview of useful existing tools and frameworks to facilitate this process. The second part includes a description of a general methodology to undertake quantitative analysis with Wikipedia data, and open source tools that can serve as building blocks for researchers to implement their own analysis process.
    [Show full text]