Chapter 2, “Beginning PHP6,Apache,Mysql web development” by Matt Doyle, Wrox publishers, 2009, ISBN: 0470413964
Chapter 3, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8.
32 trang |
Chia sẻ: dntpro1256 | Lượt xem: 641 | Lượt tải: 0
Bạn đang xem trước 20 trang tài liệu Introduction to PHP (Part-1), để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
Introduction to PHP (Part-1)Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.1OutlineSetting the environmentOverview of PHPConstants and Variables in PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.21. Setting the environment A web serverPHP MySql Dreamweaver /Adobe DreamweaverBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.3WAMP Server1. Setting the environment .Checking WAMP status:MSVCR100.dll is missingInstall Microsoft Visual C++ 2010 SP1 Redistributable PackagePort conflict with skypeBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.4WAMP is working properly2. PHP: an OverviewPHP: Hypertext PreprocessorOriginally called “Personal Home Page Tools”Used to create dynamic web pagesPopular server-side scripting technologyOpen-sourceAnyone may view, modify and redistribute source codePlatform independentBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.52. PHP: an OverviewInterpreted language, scripts are parsed at run-time rather than compiled beforehandCompatible with many popular databasesPopular server-side scripting technologyStructurally similar to C/C++Supports procedural and object-oriented paradigm Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.62. PHP: an OverviewBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.72.1 How PHP Fits with HTMLEmbedding PHP in HTML codeHTML can also be written inside the PHP codePHP can also be written as a standalone program with no HTML at allBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.82.2 Basic Rules of PHP syntaxPHP code is denoted in the page with opening and closing tags, as follows: PHP statements end with a semicolonComments can be added as// for one line comment/* and */ for multiple lines commentBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.92.3 Writing and executing PHP codeOpen a notepad or dreamweaver fileWrite PHP codeSave file with .php extensionSave all the files in one directoryCopy this directory in C:\wamp\www\Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.102.3 Writing and executing PHP codeStart WAMP serverGo to localhost either by typing localhost in address bar of the browser or by clicking the WAMP sever icon in the toolbar and selecting localhostSelect your web directory from the list of project on the WAMP server home pageSelect the file to executeBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.112.4 Writing output to the browserecho(): is used to write output on the browserecho(“Welcome to PHP”); echo “Welcome to PHP”;print(): can also be used to write out put on the browserprint(“Welcome to PHP”); print “Welcome to PHP”;printf(): can also be used for writing outputBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.122.5 First PHP programBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.13PHP block startsWriting on browserEnding PHP block2.5 First PHP programBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.14Out put from the PHP code2.6 Integrating HTML with PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.15echo statement outputs whatever it’s told to the browserIt can output not only plain text but also HTML tags echo “ Welcome to the PHP”;2.6 Integrating HTML with PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.16Using quotation marks:echo “ Welcome to PHP”; echo “ Welcome to PHP”; echo “ Welcome to PHP”; 2.6 Integrating HTML with PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.17Using headingArranging quotationsUsing escape character2.6 Integrating HTML with PHPBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.183. Using CONSTANS and VariablesBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.193.1 CONSTANTSA constant is a placeholder for a value that you reference within your code that is formally defined before using itmust begin with a letter or an underscoreare case sensitivetypically they are named using all capital lettersPHP function define() is used to assign a value to a constantBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.203.1 CONSTANTSBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.21Constant nameValue of constantDisplaying the value 3.2 VariablesBegin with $ signFirst character must be a letter or underscoreRemaining characters may be letters, numbers or underscoresDon’t need to declare or initializeCase sensitiveData types does not require to be declare explicitlySupportsFloat, integer, boolean, string, array, object Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.223.2 VariablesBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.23Variable declaredInitial valueDisplaying variable’s value3.2 VariablesBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.243.2 variablesThe gettype() function returns the type of the provided variableThe settype() function converts a variable to the type specified by typeBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.253.2 VariablesBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.262.2 VariablesBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.272.2.1 Type determinationA number of functions are available for determining a variable’s typeboolean is_name(mixed var)is_array() is_bool()is_float()is_integer() is_null() is_numeric()is_string()Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.282.2.1 Type determinationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.292.2.1 Type determinationBasharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.30SummarySetting the environment PHP overviewPHP constants and variables Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.31ReferencesChapter 2, “Beginning PHP6,Apache,Mysql web development” by Matt Doyle, Wrox publishers, 2009, ISBN: 0470413964 Chapter 3, “Beginning PHP and MySQL” by W. Jason Gilmore, Apress publisher, 4th edition; 2010, ISBN-13 (electronic): 978-1-4302-3115-8.Basharat Mahmood, Department of Computer Science,CIIT,Islamabad, Pakistan.32
Các file đính kèm theo tài liệu này:
- lec24_introduction_to_php_part1_5234_2026972.pptx