Exploring Object Oriented Language and Migration with Zend
Total Page:16
File Type:pdf, Size:1020Kb
WSEAS TRANSACTIONS on COMPUTER RESEARCH Alen Šimec, Josip Perić, Lidija Tepeš Golubić Exploring Object oriented language and migration with Zend ALEN ŠIMEC Polytechnic of Zagreb, Vrbik 8, 10 000 Zagreb, CROATIA [email protected], www.tvz.hr JOSIP PERIĆ Polytechnic of Zagreb, Vrbik 8, 10 000 Zagreb, CROATIA [email protected], www.tvz.hr LIDIJA TEPEŠ GOLUBIĆ Polytechnic of Zagreb, Vrbik 8, 10 000 Zagreb, CROATIA [email protected], www.tvz.hr Abstract: - This paper refers to the research of novelties and differences in the newest and currently active versions of PHP programming language. It gives some answers to the questions of usefulness and feasibility of changing the version used in a certain web project. The attention has been mostly focused on describing functionality with occasional evidence in the shape of a code. Key - Words: PHP, engine, memory, exception, class, object, generator separate them from the previous editions and mutually. 1 Introduction The goal of this paper is to highlight positive and useful Rapid expansion of web technologies has required a sides of the latest versions of this programming development of new approaches to data management. language by applying a mostly descriptive method with The consequence of the demand of interactive and occasional use of induction, experiments, measurements dynamic systems is the emergence of a script language and analysis. also known by the acronym PHP (Hypertext Preprocessor). Before PHP started being used, PHP web sites had been mostly static with the capacity limited to roughly show information in the form of a text of images. Integration of PHP into web spaces has enabled 2 Zend Engine System Overview interaction with the users as well as processing and Metadata is the most important part of the application of data from user sources. information management infrastructure in data repositories. The metadata is defined according to the Even though it is being performed on the server side, standards, specifications or their application profiles. it has been imagined as a communication connection between the client and the server in client-server The fifth version of PHP programming language is architecture. It has the characteristics of the code based on the exchange of mechanisms for script openness and free availability. It has been written in C implementation. The new version of Zend Engine with a programming language and it acts as a database secondary suffix has, among other things, enabled the manager. code writing in a more automated way. It represents the language core in a way that it sets predefined functions PHP has so far been published in six versions with for the development of PHP code. In addition, it various editions inside of versions. The last available provides the language with standard services such as version is PHP7, and this paper is going to be based on resource and memory management. A novelty in this the analysis of the newest and currently existent field is the addition of expandable objective models versions, that is basic features that determine them and together with improvement of basic performances. E-ISSN: 2415-1521 155 Volume 5, 2017 WSEAS TRANSACTIONS on COMPUTER RESEARCH Alen Šimec, Josip Perić, Lidija Tepeš Golubić Expandable structures also pertain to writing 3 PHP scripting language and data function arguments such as defining information about the minimal and maximal number of parameters and objects structures of transferred parameters. Object classes can The next influential extension that is being be implicitly demanded when calling which ensures the introduced into the language are PDO objects that reception of requested data. Otherwise, fatal error enable consistency of application programming interface occurs. between data base extensions. Such objects simplify the creation of applications that are mostly dependent on data base access and managing the saved data. By using <?php the advantages built into the fifth language version, the function transfer(Player $player, Club $club){ script performance has been overridden by the original echo ''transferring '' . $player->name . '' to '' . $club- C code in a way that the parts specific for the base have >name ; been separated into a special extension. } The most remarkable benefit of using PDO objects is Code 1 –Defining function arguments the possibility of reusing. Beside reducing the number of code lines, such implementation simplifies the change of technologies provided that the substitute access also According to the stated function declaration, the first supports the object-oriented paradigm. entry parameter has to be a class Player object, and the For performing tasks of the interface through which second one class Club. If a null default value is set for the communication with the bases is being performed, an argument, then it is possible for it to be forwarded. has been structured with two key classes: PDO that is This way of defining arguments is being called type being used for establishing communication and direct hinting. communication and PDOStatement that refers to the Additional code implementations, such as parameter request and the result in the opposite direction. [4] information, are being demanded from the author when From the existing methods related to PDOStatement creating extensions. The header of the wanted structure it is necessary to emphasize: can be defined by two forms: • • ZEND_BEGIN_ARG_INFO() lastInsertId() –for the return value it gets the last line inserted into the base • ZEND_BEGIN_ARG_INFO_EX() • columnCount() –it restores the number of columns The difference lies in the fact that the second in the set of results performance enables restrictions in the number of mandatory parameters. There is a similar situation when • rowCount() –it restores the number of lines in the defining the parameters themselves where the following set of results functions are being differentiated: • fetch() –it restores the next line from the set of • ZEND_ARG_INFO() results • ZEND_ARG_OBJ_INFO() • fetchAll() –it restores the field that contains all the Zend_arg_obj_info() Function specifies the lines of the set of results parameter by marking the parameter class and the • fetchObject() –it fetches the next line in the form of possibility of setting NULL values. an object PHP5 in this way frees the author of checking the • exec() –it is being used for adding, changing and number of forwarded parameters by placing the load on deleting lines the side of Zend Engine. Beside the above stated functions, functions such as Zend Engine changes have resulted in enormous prepare() and bindParam() that particularly emphasize increase in speed, performances and memory the multiple code usability are often being used. For consumption. For example, a website launched on PHP7 example, the prepare() method is being oriented at the can reach a doubled number of performed requests per use of reserved places in a way that the request is being second during a half as long testing time in comparison defined one time, and then later used multiple times. to the same one launched on PHP5. The stated statistical values of handling requests are the best way of showing progress in the newest PHP version. Despite the $query= $db->prepare("INSERT INTO players(name, obviously positive characteristics, it is necessary to position) VALUES (:name, carefully approach the transition to PHP7 due to the :position) "); changes in functions and extensions, and especially in $query->execute(array(':name'=>'John', specific cases of removing those. Moreover, many ':position'=>'Striker')); services still do not support the changes made. Fig. 2 – Use of prepare() method In this way SQL attacks are being automatically disabled. In the case of unnamed reserved places a E-ISSN: 2415-1521 156 Volume 5, 2017 WSEAS TRANSACTIONS on COMPUTER RESEARCH Alen Šimec, Josip Perić, Lidija Tepeš Golubić question-mark symbol is being placed where the value 3.1 Exceptions handling parameter should be. Changes in exceptions handling in different versions Often in combination with prepare() function come of PHP5.x, one of the modules that has undergone a bindValue() and bindParam(). Simplified request complete reconstruction is error handling. To be precise, creation represents a visible advantage of the stated exceptions handling has relieved the developer from the structure. The difference is being noted when giving need of doing an additional check of return value of each data to the reserved places. In the case of merging of function. Similarly to the previously mentioned values it is about setting variable values to a separated database performance, exceptions and error placeholder, while the merging of parameters refers to handling has also been separated from the software the variable that is being transferred through a reference. logic. A common feature of both functions is the usage prior to The structure and the task of exceptions handling is performed requests. almost identical to the ones in programming languages such as Java and C++. If the catching of exception is not $query= $db->prepare("INSERT INTO players(name, being defined, an error of uncaught error occurs. [5] position) VALUES (?, ?) "); <?php $player = array(''John'',''Striker''); function provjeraSume($br1, $br2) { $query->bindValue(1, $player[0]); if(($br1+$br2)<10){ $query-bindValue(2, $player[1]); throw new Exception("Suma mora biti veća ili jednaka $query->execute(); 10"); Fig. 3 – Use of bindValue() method } return true; $query= $db->prepare("INSERT