🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

APPLICATIONS DEVELOPMENT AND EMERGING TECHNOLOGIES MODULE 1: WEB ARCHITECTURE, TOOLS, AND INTRODUCTION TO PHP AN INTRODUCTION TO PHP WEB ▪ PERL Compatible Regular PROGRAMMING Expressions...

APPLICATIONS DEVELOPMENT AND EMERGING TECHNOLOGIES MODULE 1: WEB ARCHITECTURE, TOOLS, AND INTRODUCTION TO PHP AN INTRODUCTION TO PHP WEB ▪ PERL Compatible Regular PROGRAMMING Expressions New features, power, and scalability History PHP 5 (July 13, 2004) 1994/1995 (PHP 1.0) Vastly improved object-oriented Developed by Rasmus Lerdorf capabilities: OOP improvement To know how many visitors were Try/catch exception handling reading his online resume based on Improved XML and Web Services PERL/CGI script support (Simple XML Support, using Personal Home Page (PHP) SOAP) 1997 (PHP 2.0) Native support for SQLite Installed on 19 million domains PHP is based on C rather than PERL 54 percent on all Apache module Personal Home Page/Form Interpreter PHP 6 (2007 not yet released) 1998 (PHP 3.0) Unicode Support (Native Unicode 50,000 users were using PHP to support for multilingual applications enhance their Web pages Security improvements Developers joined Lerdorf New language features and constructs 1999 (PHP 4.0) (64-bit type integer, foreach looping) With core developers Zeev Suraski and Introduction to PHP Andi Gutmans PHP code is executed on the server. PHP makes the most popular scripting PHP is one of the most widely used language with more than one million server-side scripting language for web user base by Netcraff development. Popular websites like Hundreds of functions being added Facebook, Yahoo, Wikipedia etc., and Dubbed the Zend scripting engine our very own Study tonight, are developed using PHP. May 22, 2000 (PHP 4.0) PHP is so popular because it's very PHP: Hypertext Preprocessor (recursive simple to learn, code and deploy on acronym) server, hence it has been the first choice 3.6 million domain PHP installed for beginners since decades. Enterprise development What you should already know ▪ Improved resource handling (scalability) Before you continue you should have a basic ▪ Object-oriented support (Classes understanding of the following: and Objects) HTML ▪ Native session-handling support (session) CSS ▪ Encryption (encryption algoritms) JavaScript ▪ ISAPI Support (for IIS) What is PHP? ▪ Native COM/DOM (Windows applications) PHP is an acronym for "PHP: Hypertext ▪ Native Java Support: (binding to Preprocessor" java objects) PHP is a widely-used, open source If you are still confused about whether you scripting language should learn PHP or is PHP the right language PHP scripts are executed on the server for your web project, then here we have listed PHP is free to download and use down some of the features and use cases of PHP language, which will help you understand PHP stands for Hypertext Pre-Processor. PHP how simple yet powerful PHP scripting is a scripting language used to develop static language is and why you should learn it. and dynamic webpages and web applications. Here are a few important things you must know 1. PHP is open source and free, hence you about PHP: can freely download, install and start developing using it. 1. PHP is an Interpreted language, hence it 2. PHP has a very simple and easy to doesn't need a compiler. understand syntax, hence the learning 2. To run and execute PHP code, we need curve is smaller as compared to other a Web server on which PHP must be scripting languages like JSP, ASP etc. installed. 3. PHP is cross platform, hence you can 3. PHP is a server side scripting language, easily develop and move/deploy your which means that PHP is executed on PHP code/project to almost all the major the server and the result is sent to the operating systems like Windows, Linux, browser in plain HTML. Mac OSX etc. 4. PHP is open source and free. 4. All the popular web hosting services PHP is an amazing and popular language! support PHP. Also the web hosting plans for PHP are generally the amongst It is powerful enough to be at the core of the cheapest plans because of its the biggest blogging system on the web popularity. (WordPress)! 5. Popular Content Management Systems It is deep enough to run the largest like Joomla, Drupal etc. are developed social network (Facebook)! in PHP and if you want to start your own It is also easy enough to be a beginner's website like Study tonight, you can first server-side language! easily do that with PHP. 6. With PHP, you can create static and What is a PHP File? dynamic webpages, perform file PHP files can contain text, HTML, CSS, handling operations, send emails, JavaScript, and PHP code access and modify browser cookies, and PHP code is executed on the server, almost everything else that you might and the result is returned to the browser want to implement in your web project. as plain HTML 7. PHP is fast as compared to other PHP files have extension ".php" scripting languages like JSP and ASP. 8. PHP has in-built support for MySQL, What Can PHP Do? which is one of the most widely used PHP can generate dynamic page Database management system. content Why PHP? PHP can create, open, read, write, delete, and close files on the server PHP runs on various platforms PHP can collect form data (Windows, Linux, Unix, Mac OS X, etc.) PHP can send and receive cookies PHP is compatible with almost all PHP can add, delete, modify data in servers used today (Apache, IIS, etc.) your database PHP supports a wide range of PHP can be used to control user-access databases PHP can encrypt data PHP is free. Download it from the official With PHP you are not limited to output PHP resource: www.php.net HTML. You can output images, PDF PHP is easy to learn and runs efficiently files, and even Flash movies. You can on the server side also output any text, such as XHTML PHP Key Categories and XML. Practicality Is PHP the right language? PHP is a loosely type language (no Lion tiger explicitly create, typecast, or destroy a Panther variable) Internet Browser Power Google Chrome Native support is offered for more than Mozilla Firefox 25 database products, including Adabas Internet Explorer D, dBase, Empress, FilePro, FrontBase, Opera Hyperwave, IBM DB2, Informix, Ingres, Safari InterBase, mSQL, Microsoft SQL Maxthon Server, MySQL, Oracle, Ovrimos, Rockmelt PostgreSQL, Solid, Sybase, Unix dbm, SeaMonkey and Velocis. Deepnet Explorer Both structured and Object Oriented Avant Browser approach Web Server Power Apache Free of charge Internet Information Services (IIS7) Web Architecture NGiNX Google Web Server (GWS) Server Side Scripting Language Java (JavaServer Pages: JSP) Ruby (Ruby on Rails) Active Server Pages (ASP) Python (Django) PERL CGI PHP Database Software Requirements IDM DB2 MySQL Operating System: Linux Microsoft SQL Server Ubuntu SQLite Debian PostgreSQL Linux Mandrake ORACLE Suse Code Editor Fedora centOS aptana kubuntu eclipse Bluefish Operating System: Windows Dreamweaver Windows xp NetBeans Windows Me Notepad++ Windows Server 2008 Other Windows 7 Windows 8 HTML Windows 2000 AJAX CSS Operating System: Mac JavaScript Cheetah jQuery Puma XAMPP/WAMP Jaguar Uses of PHP Leopard Snow leopard To further fortify your trust in PHP, here are a PHP performs system functions, i.e. from files few applications of this amazing scripting on a system it can create, open, read, write, language: and close them. The other uses of PHP are: 1. It can be used to create Web PHP can handle forms, i.e. gather data applications like Social from files, save data to a file, thru email Networks(Facebook, Digg), you can send data, return data to the Blogs(Wordpress, Joomla), eCommerce user. websites(OpenCart, Magento etc.) etc. You add, delete, modify elements within 2. Command Line Scripting. You can write your database thru PHP. PHP scripts to perform different Access cookies variables and set operations on any machine, all you need cookies. is a PHP parser for this. Using PHP, you can restrict users to 3. Create Facebook applications and easily access some pages of your website. integrate Facebook plugins in your It can encrypt data. website, using Facebook's PHP SDK. 4. Sending Emails or building email Characteristics of PHP applications because PHP provides with Five important characteristics make PHP's a robust email sending function. practical nature possible: 5. Wordpress is one of the most used blogging (CMS) platform in the World, Simplicity and if you know PHP, you can try a Efficiency hand in Wordpress plugin development. Security Flexibility PHP started out as a small open source project that evolved as more and more people found Familiarity out how useful it was. Rasmus Lerdorf Running PHP Script unleashed the first version of PHP way back in 1994. PHP is a recursive acronym for "PHP: Hypertext Preprocessor". PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e- commerce sites. It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server. PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL All PHP scripts must enclosed with server, once started, executes even very (standard tag) complex queries with huge result sets in record-setting time. (short open tag) PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java … and distributed object architectures (script tag) (COM and CORBA), making n-tier development a possibility for the first (asp style tag) time. Output: PHP is forgiving: PHP language tries to be as forgiving as possible. PHP Syntax is C-Like. Common Uses of PHP $age, $firstName, $totalSalary, $_myValue, $str1, $tmp01 Using ‘ ’ (pair single quote), “ ” (pair double quotes) and. (dot character) PHP 1. Strings inside the ‘ and ‘ are interpreted as literal strings ▪ To display a ‘ character (single quote) as string use the escape character \ (backslash). – closing tag for php script ▪ $ inside “ and “ are interpreted as ; – statement terminator variables thus it will display the value rather than the string that echo – is a language construct that use to starts with $. output one or more string. ▪ To display the string that starts print – is a function also use for outputting with $ and to display the double strings. quote as string use the escape character \ (backslash). PHP Comments 3. To concatenate string values use the. (dot or period) character thus “abc“.”def” yields to a value “abcdef” Example: // - single line comment (C syntax) # - single line comment (PERL style) Output: - multiline or block comments PHP Variables Variables are used as a container for values that can be used and manipulate PHP scripts. Variables in PHP must begin with a $ symbol. Outputting Data Variable might contain a string, echo syntax numbers, arrays and objects. Setting the identifier for a variable must void echo (string argument1 [, …string follow some rules. argument] 1. First character can be ‘_’ or a letter. print syntax 2. It can only contain alpha-numeric characters and underscore (a-z,A- int print (argument Z,0-9,_). printf syntax 3. Don’t use white space in naming a variable. boolean printf (string format [, mixed Variables in PHP is not explicitly args]) declared Example: Variables are case sensitive Example: Datatypes - is the generic name assigned to any data sharing a common set of characteristics. Scalar Datatypes - Capable of containing a single item of Output: information (Boolean, Integer, Float (float, double or real numbers), String) Example: Commonly Used Type Specifiers for printf function Type Description %b Argument considered an integer: presented as a binary number. Compound Datatypes %c Argument considered - allow for multiple items of the same type an integer: presented as a character to be aggregated under a single corresponding to that representative entity. (Array and ASCII value. Objects) %d Argument considered example: an integer: presented as a signed decimal number. %f Argument considered a floating-point number: presented as a floating-point number. %o Argument considered an integer: presented as an octal number. %s Argument considered a string: presented as string. %u Argument considered an integer: presented as an unsigned decimal number. %x Argument considered an integer: presented as a lowercase hexadecimal number. %X Argument considered an integer: presented as an uppercase hexadecimal number. PHP Datatypes Example: Output: PHP Type Casting Operators Cast Operators Conversion Array Array bool or Boolean Boolean int or integer Integer int64 64-bit integer (introduced in PHP 6) object Object real or double or float Float string String Predefined Type Functions gettype() function Example: - returns the type of the variable. Possible return values are integer, double, boolean, string, array, object, resource, unknown types. prototype: string gettype(mixed var) settype() function - converts a given variable to a specific type. prototype: boolean settype(mixed var, string type) predefined Type Identifier Functions is_array() Output: is_bool() is_float() is_integer() is_null() is_numeric() is_object() is_resource() is_scalar() is_string() Example: PHP is a server-side scripting language that runs its application on a Web server. Much of the PHP syntax were derive from C programming Language. You can integrate database easily in PHP. Standard PHP script are enclosed by tags. Each statement in PHP must be terminated with a semi-colon(;). All variable in PHP must have a dollar ($) character before its identifier. PHP variables are not explicitly declared. You can use echo, print, or printf function for outputting strings to internet browser. Output: You can enclosed string using a pair of single quote or pair of double quote. String inside a pair of single quote interpreted as literal except for the single quote itself. String inside a pair of double quote interpreted as literal with some exception like using dollar character. MODULE 1 SUMMARY To explicitly display the character on the internet browser use backslash (\) PHP was developed originally by character like \$, \’, \” and etc. Rasmus Lerdorf Datatypes in PHP can be categorized as Seev Suraski and Andi Gutsman were scalar or compound datatypes. the one who contribute most in PHP You can explicitly change the type of a development. variable in PHP. PHP key categories are practicality, PHP support some predefined type power, possibility, and price. function that can be used in PHP is a embedded language that is manipulating type variables. commonly embedded on HTML MODULE 2: PHP OPERATORS AND CONTROL STRUCTURES OPERATORS AND Left Boolean AND, XOR OR Boolean XOR, Operators Boolean OR , Left Expression An operator is a symbol that specifies a separation; particular action in an expression. example: $days What is Operator? = array(1=>”Mond Simple answer can be given using ay”, expression 4 + 5 is equal to 9. Here 4 2=>”Tuesday”) and 5 are called operands and + is called operator. Operator Precedence PHP language supports following type of Is a characteristic of operators that operators. determines the order in which they Arithmetic Operators evaluate the operands surrounding Comparison Operators them. Logical (or Relational) Operators Assignment Operators Conditional (or ternary) Operators Operator, Precedence, Associativity, and Purpose Operator Associativity Purpose new NA Object Output: instantiation () NA Expression subgrouping [] Right Index enclosure ! ~ ++ -- Right Boolean NOT, bitwise NOT, increment, decrement Operator Associativity @ Right Error Is a characteristic of an operator suppression - symbol used for multi-line ?> comment. What is the output? Answer: Welcome to PHP 51. Try/catch exception handling introduce } in what version of PHP? PHP5 What is the function name inside of the 52. &&|| - Operator for Boolean AND, code? Boolean OR. 53. == - symbol for equal to. Answer: one 54. % - symbol for modulus. 55. Operator Precedence – characteristic 5. function a($a,$b){ of operators that determines the order in return $a+$b; which they evaluate the operands } surrounding them. 56. - - symbol for subtraction. echo a(6,5); 57. $x=10; What is the value of $a? Echo ++$x; What is the output? Answer: 6 Answer: 11 6. FALSE – Global Variables is declared 58. ++ - increment symbol inside a function and is only available 59. $u=30; within the function in which it is do{ declared. echo $y++; 7. What do you call a function inside of a } while ($u0){ 9. krsort($array) – Sorts by key in reverse echo $a--.” “; order. } 10. $num = array(1,2,3,4,5); What is the output if $a is 5? foreach(num as $val){ Answer: 5 4 3 2 1 echo $val; } FA3 1. $f = array( Check if the code is valid or invalid? ‘102’ => “red”, Answer: Invalid ‘101’ => “blue”, 11. TRUE – Using foreach statement you ‘100’ => “yellow”; can display both the keys and value of ksort($f); each element in the array. print_r($f); 12. FALSE – asort() and arsort() used to sort elements by keys. What is the output of the code? 13. Array index – references a Answer: Array ( => yellow corresponding value. => blue => red) 14. TRUE – specify an array expression within a set of parenthesis following the 2. $f = array( foreach keyword. ‘102’ => “red”, 15. TRUE – The foreach statement is used ‘101’ => “blue”, to iterate through the element in an ‘100’ => “yellow”; array. krsort($f); 16. function a($a,$b){ print_r($f); return $a+$b; What is the output of the code? } Answer: Array ( => red => echo a(5,4); blue => yellow) What is the output of the code? 3. TRUE – Array index is also known as Array Keys. Answer: 9 4. $t = 100; 17. sort($array) – Sorts by value; assign function one(){ new numbers as the keys. echo “value”; 18. $g = 200; function a(){echo “5”;} function b(){echo “4”;} 34. FALSE – Functions are limited to 1 per a();b(); code only. 35. Function count($val){ What is the output of the code? static $c = 0; Answer: 54 $c += 0; 19. TRUE – Functions is a group of PHP echo $c; statements that performs a specific task. } 20. $mo = array(“jan”,”feb”,”mar”); echo “”; Count(4); var_dump($mo); echo “”; Count(3); Check the code if valid or invalid? What is the output of the code? Answer: Valid 21. var_dump() – prints additional Answer: error information about the size and type of 36. arsort() – Sorts by value in reverse the values it discovers. order; keeps the same key. 22. TRUE – A function that is declared 37. Local Variables – is declared inside a inside a function is said to be hidden. function and is only available within the 23. TRUE – You can pass values to a function in which it is declared. function and you can ask functions to 38. foreach($arr as $value) return a value. 39. TRUE – You can create your own 24. foreach($arr as $value) function inside of a php code. 25. $f = array( 40. $fruit = ‘102’ => “red”, array(“orange”,”apple”,”grape”,”banana”) ‘101’ => “blue”, ; ‘100’ => “yellow”; What is the value of index 2? ksort($f); Answer: grape print_r($f); 41. User defined function – functions that What is the key of the yellow? are provided by the user of the program. Answer: 100 42. Function count($val){ 26. FALSE – You can use only 10 for Array $c = 0; elements $c += $val; 27. print_r() – This takes an argument of echo $c; any type and prints it out, which includes printing all its parts recursively. } 28. $g = 200; count(10); function a(){echo “5”;} function b(){echo “4”;} count(5); b(); What is the output of the code? What is the output of the code? Answer: error Answer: 4 43. TRUE – sort(), asort(), and ksort() 29. function – is the keyword used to functions are used to sort elements in declare a function. the array in ascending order. 30. TRUE – sort() and rsort() does not 44. Functions – is a group of PHP maintain its index reference for each statements that performs a specific task. value. Functions are designed to allow you to 31. Array – is used to aggregate a series of reuse the same code in different similar items together, arranging and locations. dereferencing them in some specific 45. TRUE – Each member of the array way. index references a corresponding value 32. $fruit = and can be simple numerical reference array(“orange”,”apple”,”grape”,”banana”) to the value’s position in the series, or it ; could have some direct correlation to the What is the value of index 3? value. Answer: banana 46. function a($a,$b){ 33. TRUE – Array is used to aggregate a return $a+$b; series of similar items together. } 59. print_r() – function is used to print the array structure. echo a(5,4); 60. $fruit = What is the name of the parameter? array(“orange”,”apple”,”grape”,”banana”) ; Answer: $a and $b What is the value of index 1? 47. $fruit = Answer: apple array(“orange”,”apple”,”grape”,”banana”) 61. FALSE – PHP array does need to ; declare how many elements that the What is the value of index 0? array variable have. 62. $s = “variable”; Answer: orange function f(){ 48. TRUE – param – is the formal global $s; parameters of the function. Parameter echo “function called ”; must follow the rule of naming dentifier. echo “$s”; 49. function disp(){ } function disp2(){ f(); echo “hello”; What is the output of the code? } Answer: function called variable 63. foreach($arr as $key => $value){ } // do something disp2(); } 64. FALSE – Functions can only have 1 Answer: Error parameter. 50. TRUE – asort(), ksort(), arsort(), and 65. function disp(){ krsort() maintains its reference for each function disp2(){ values. echo “hello”; 51. TRUE – You can use functions in } different ways. } 52. TRUE – sort() and rsort() does not maintain its index reference for each disp(); values. disp2(); 53. TRUE – PHP has a built-in function to perform operations. Answer: hello 54. TRUE – Function can have a return 66. usort($array) – sorts by a function. value. 67. TRUE – function keyword is used in 55. $g = 200; PHP to declare a function. function a(){echo “5”;} 68. TRUE – You can insert CSS code inside function b(){echo “4”;} of a function. a(); 69. rsort($array) – sorts by value in reverse order; assign new number as the keys. What is the output of the code? 70. $num = array(1,2,3,4,5); foreach($num as $val){ Answer: 5 echo $val; 56. TRUE – rsort(), arsort(), and krsort() } functions are used to sort elements in What is the output of the code? the array in descending order. Answer: 12345 57. TRUE – we use the static keyword to 71. foreach() – is a statement used to declare a variable inside a function that iterate or loop through the element in an will act as accumulator variable this will array. let the program remember the last value FA4 of the variable that was used. 58. print_r() and var_dump() – functions 1. $t = 100; are commonly used for debugging. The function one(){ point of these functions is to help you echo “1000”; visualize what’s going on with } compound data structures like arrays. one(); What is the value of the $t after execute 20. strtolower – converts string to the code? lowercase Answer: 100 21. $x = rand(5,10); echo $x; 2. TRUE – Array can be used as ordinary What is the minimum value of the array same as in C and C++ arrays. output? 3. $t = 100; Answer: 10 function one(){ 22. int strlen (string $string) – syntax for echo “1000”; length of a string. } 23. $s = “variable”; one(); function f(){ What is the function name inside the echo “function called ”; code? echo “$s”; Answer: one } 4. foreach($arr as $value) – Syntax for f(); foreach What is the output of the code? 5. asort() – Sorts by value; keeps the Answer: function called undefined same key. variable: s 6. Function count($val){ 24. What is the keyword use to gain access $c = 0; a variable that is outside of the function? $c += $val; Global echo $c; 25. Array can be used as ordinary array same as in C and C++. } 26. define – used to declare constants. Count(10); 27. j – Format character for a day of the month without leading zeros. Count(5); 28. s – Format character for English ordinal What is the output of the code? suffix for the day of the month, 2 Answer: Error characters. 7. TRUE – PHP array does not need to 29. require(“filename.inc”); - Syntax for declare how many elements that the require array variable have. 30. D – Format character for a textual 8. TRUE – Number format can show or representation of the day, three letters. hide the decimal place. 31. include_once(“filename.inc”) – syntax 9. strrev – reverse a given string. for include once 10. $x = ceil(10.01); echo $x; 32. y – Format character for a two digit What is the output? representation of a year. Answer: 11 33. $x = floor(7.2); echo $x+1; 11. string strtolower (string $str) – syntax What is the output? to transform a string to lower case. Answer: 8 12. array explode (string $delimiter, 34. rand() – used to generate random string $string [, int $limit]) – syntax for integers. explode 35. string substr (string $string, int $start 13. string trim(string $str [, string [, int $length]) – syntax to get a part of $charlits]) – syntax to stripped white a given string. spaces or other characters from the 36. M – Format character for a short textual beginning and end of a string. representation of a month, three letters. 14. define – keyword to declare a define 37. Function name(param){ } – Syntax for function. a function 15. TRUE – A constant’s value cannot be 38. Array index in PHP can be also called changed. Array keys. 16. floor() – returns the next lowest integer 39. TRUE – it is required to create a by rounding the value downwards. function name for a function. 17. Constant – can only be assigned a 40. Global Variables – is one that declared scalar value, like a string or a number. outside a function and is available to all 18. l – format character for a full textual parts of the program. representation of the day of the week. 41. int strops (string $haystack, mixed 19. number_format – syntax for a number $needle [, int $offset = 0]) – syntax for format. position of a string. 42. include_once – Same as include 66. int rand(int $min, int $max) – Syntax function except it includes the file only for random number with minimum and once. maximum value. 43. unset – destroys the specified variable. 67. Number format – format a number with 44. F – Format character for a full textual grouped thousand. representation of the month, such as 68. strlen – return the value length of a January or March. string. 45. Most of the developers used include 69. TRUE – Including files can use to write functions for their Footer. their database connection and so on. 46. mixed max(mixed $value) – syntax for 70. require_once – same as require maximum value. function except it includes the files only 47. string strip_tags(string $str [, string once. $allowable_tags]) – Syntax to strip 71. strops – find the position of the first HTML and PHP tags from a string. occurrence of a substring in a given 48. int rand(void) – syntax for random string. 49. include – Includes and evaluates the 72. TRUE – Functions are designed to allow specified file. Generate a warning on you to reuse the same code in different failure message if file not found. locations. 50. string strrev(string $string) – syntax 73. $a[]=”mango”; for reverse a string. $a[]=”apple”; 51. Y – Format character for a full number $a[]=”banana”; representation of a year, 4 digits. Check the code if valid or invalid? 52. float ceil(float $value) – syntax for ceil Answer: Valid 53. string ucwords(string $str) – Syntax to 74. TRUE – In some scripts, a file might be converts the first character of each word included more than once, causing in a string to uppercase. function redefinitions, variable 54. w – Format character for numeric reassignments, and other possible representation of the day of the week. problems. 55. $x = main(10, 5, 3, 20); echo $x; 75. $x = rand(5,10); echo $x; What is the output? What is the maximum value of the Answer: 3 output? 56. $val=356342.783 Answer: 10 echo number_format($val,2,”.”); 76. TRUE – You can separate your PHP file What is the output? and embed it to your HTML by using Answer: 356,342.78 include functions. 57. rtrim() – strip white spaces of other 77. define(‘Max_n’.10); characters from the end of a string. What is the name of the define function? 58. $x = max(5.3, 5, 6, 3); echo $x; Answer: Max_n What is the output? 78. m – Format character for numeric Answer: 6 representation of a month, with leading 59. trim() – stripped white spaces or other zeroes. characters from the beginning and end 79. string date(string $format [, int of a string. $timestamp = time() ]) – Syntax that 60. t – Format character for number of days used to format a local time and date. in the given month. 80. $val = 234123.456; 61. d – Format character for day of the echo number_format($val); month, 2 digits with leading zeros. What is the output? 62. TRUE – Functions can be user defined Answer: 234,123 generally defined by the user of the 81. $val = 643322.7834 program and predefined that are build in echo number_format($val,3’.’,’,’); using libraries. What is the output? 63. FALSE – Function can be put Answer: 643,322.783 anywhere of the code. 82. define(‘NAME’,’value’); - Syntax of 64. ucwords() – converts the first character define of each word in a string to uppercase. 83. a – Format character for lowercase Ante 65. TRUE – There will be a warning text if meridiem and Post meridiem. the include file not found. 84. substr – returns part of a given string. FA5 21. PHP_SELF – contains the filename of the currently executing script. 1. TRUE – the session_destroy() 22. u – Regular Expression pattern modifier statement does not affect the variables for pattern is treated as UTF-8. set on the current page. 23. TRUE – Cookies are mechanism for 2. \W – Regular Expression Meta storing data in the remote browser and characters symbol for any non alpha thus tracking or identifying return users. numeric characters. 24. [abc] – Regular Expression Meta 3. ” information. method=”post”> 23. ‘/hello/’ – Regular expression example that will match the word hello. Check of the code if it is valid or invalid 24. setcookie() – managing cookies can be Answer: Valid done using function. 46. print_r($_COOKIE) – Syntax to display 25. unset($_SESSION[‘varname’]) – cookies. syntax for unset session variables. 47. a? – Regular Expression Meta 26. m – Regular Expression pattern modifier characters Symbol for Zero or one ‘a’ for multinet mode. character. Equals to a(0,1). 27. mysql> - MySQL prompts means ready for a new command. FA6 28. TRUE – One important aspect of database management is its querying 1. what is R in PCRE – Regular capability. 2. FALSE – PCRE means Perl Compatible 29. TRUE – You can update multiple Regular Expression columns. 3. Session – is the time that a user spends 30. TRUE – DML is use for creating queries. at your Web site. 31. DELETE FROM WHERE 4. Session – are mechanism for storing = ; - syntax data on the server itself. for deleting a column. 5. [^abc] – Regular Expression Meta 32. \h – code for showing help in MySQL. characters Symbol for not in range 33. TIME – Type of Field data types that (every character except a, b, or c). range of HH:MM:SS. 6. INSERT INTO – command for inserting 34. ALTER TABLE tblname ADD field a value to your table. char(1) – syntax to add new column. 7. CREATE – command to create a 35. /*> - MySQL prompts means waiting for database. next line, waiting for completion of a 8. INSERT INTO VALUES comment that began with /*. (value1, value2, value3, …); - syntax 36. Fields – are the individual categories of for inserting a value to your table. information stored in a record. 9. INT – Type of field data types that - 37. Select current_date(): - command in 2147483648 to 2147483647. MySQL to display the current date. 10. INSERT INTO (column 38. TRUE – mSQL was distributed as name) VALUES (value); - Syntax for shareware. inserting values in a specific column. 39. a+ - Regular Expression Meta 11. BOOL – Type of Field data types that characters Symbol for one or more of range -128 to 127; 0 is considered false. ‘a’. 12. UPDATE – command for updating the 40. a{5,10} – Regular Expression Meta records. characters symbol for between five to 13. \c – command to clear in MySQL. ten of ‘a’. 14. TRUE – MySQL is portable. 41. what is E in PCRE – Expression 15. SELECT * FROM - SQL 42. which of the following will show cookies command to view all records in the after 1 minute – table. setcookie(“name1”,”value1”,time()+6 16. Database – is an ordered collection of 0); information from which a computer 43. $_GET – an associative array variables program can quickly access. passed to the current script via the URL 17. Flat-File – database that stores parameters. information in a single table. 44. ^ - Regular Expression Meta characters 18. Select version(); - command to display Symbol for mark the start of a string. the SQL version. 45. () – Regular Expression Meta characters 19. What is D in DML? – Data Symbol for group elements. 20. DESCRIBE – command to display the 46. MySQL – Developments of lightweight structure of the table. storage tools for websites. 21. a* - Regular Expression Meta characters 47. USE ; - syntax for using Symbol for zero or more of ‘a’. database. 48. Which of the following is not Command 17. touch(“$file”) – syntax for attempts to help in MySQL? – Gethelp create an empty file. 49. SHOW tables – command to display the 18. $query = mysql_query(“SELECT list of table. MIN(tuition) FROM tblinfo”); 50. TRUE – you can insert a values in a $fetch = mysql_fetch_array($query); specific column. echo $fetch [“MIN(tuition)”]; 51. Select now() – command in MySQL to Check the code if valid or invalid display today’s date and time. Answer: Invalid 52. Varies – Field data types Storage value 19. TRUE – In creating a file, If the file of DATE. already exists, its contents won’t be 53. SHOW – command to show database. disturbed. 54. DROP – command to delete a table 20. feof() – use to tell the last line of a file. 21. $query = mysql_query(“SELECT FA7 MAX(tuition) FROM tblinfo”); $fetch = mysql_fetch_array($query); 1. $query = mysql_query(“SELECT echo $fetch [“MAX(tuition)”]; MIN(tuition) FROM tblinfo”); Check the code if valid or invalid $fetch = mysql_result($query,0); Answer: Invalid echo $fetch; 22. Row – the row number from the result Check the code if valid or invalid that’s being retrieved. Row numbers Answer: Valid start at 0. 2. mysql_num_rows() – retrieves the 23. $result_query – the result resource that number of rows from a result set. is being evaluated. This result comes 3. mysql_result($result_query, row, from a call to mysql_query(). field) – syntax to retrieves the contents 24. fgetc(“$file”) – syntax to read a file per of one cell from a MYSQL result set. character. 4. TRUE – Using the global PHP $_FILES 25. fopen() – is used to open a file for array you can upload files from a client reading, writing, or appending content. computer to the remote server. 26. $query = mysql_query(“SELECT 5. $query = mysql_query(“SELECT name MAX(tuition) FROM tblinfo”); FROM tblinfo”); $fetch = mysql_result($query,0); $fetch = mysql_result($query,2); echo $fetch In this code it will get the name of what Check the code if valid or invalid row? Answer: Valid Answer: 3rd 27. Complete the syntax: 6. Field – The name or offset of the field mysql_result($result_query,row,field) being retrieved 28. unlink() – a function used to remove an 7. SUM – SQL command that will get the existing file. sum of a specified field. 29. feof(“$file”) – syntax to tell the last line 8. fopen(“test.txt”,”w”) – syntax to open of a file. a file for writing. 30. TRUE – mysql_num_rows() is only valid 9. is_executable() – checking the file for statements like SELECT or SHOW status if executable. that return an actual result set. 10. fopen(“file”,”mode”) – syntax for 31. fputs() – other command for fwrite(). opening a file. 32. move_uploaded_file() – function to 11. is_file() – checking if it is a file. save permanently the uploaded file. 12. Complete the syntax: 33. file_exists() – checking for file mysql_result($result_query,row,field) existence 13. $_FILES – array you can upload files 34. TRUE – mysql_result() retrieves the from a client computer to the remote contents of one cell from a MySQL server. result set. 14. fwrite(“$file”,”text”) – syntax for 35. Complete the syntax: accepting a file resource and a string, $_FILES[“file”][index] and then writes the string to the file. 36. Complete the syntax: 15. Complete the syntax: mysql_result($result_query,row,field) $_FILES[file][“index”] 37. $query = mysql_query(“SELECT 16. Complete the syntax: MAX(tuition) FROM tblinfo”); move_upload_file(file,new location); $fetch = mysql_fetch_array($query); echo $fetch; 46. fgetc() – use to read a file per character. Check the code if valid or invalid 47. mysql_result() – retrieves the contents Answer: Valid of one cell from a MYSQL result set. 38. filesize() – determining the file size 48. fgets(“$file”,1024) – syntax to read a 39. FALSE – mysql_rows() get the number line from a file. of affect rows by the last SELECT, 49. fopen(“test.txt”,”r”) – syntax to open a INSERT, UPDATE, REPLACE or file for reading. DELETE query. 50. fopen(“test.txt”,”a”) – syntax to open a 40. mysql_affected_rows() – get the file for appending number of affected rows by the last 51. complete the syntax: SELECT, INSERT, UPDATE, REPLACE move_upload_file(file,new location); or DELETE query. 52. $query = mysql_query(“SELECT 41. fread(“$file”,1) – syntax to read a MIN(tuition) FROM tblinfo”); specified set of character in a file. $fetch = mysql_fetch_array($query); 42. is_dir() – checking if it is a directory. echo $fetch; 43. fread() – use to read a specified set of Check the code if valid or invalid characters in a file. Answer: Valid 44. is_readable() – checking the file status if readable 45. FALSE – Before removing or deleting files you need to indicate the extension file name of the file.

Use Quizgecko on...
Browser
Browser