Tag Archives: string

Php Interview Questions and Answers – Part 9

images




1- How can we know that a session is started or not? A session starts by session_start() function. This session_start() is always declared in header portion. it always declares first. then we write session_register(). 2- What are the differences between  mysql_fetch_array(),  mysql_fetch_object(),  mysql_fetch_row()? Answer 1: mysql_fetch_array() -> Fetch a result row as a combination of associative array and regular array. mysql_fetch_object() -> Fetch a result row as an object. mysql_fetch_row() -> Fetch a result set as a regular array(). Answer […]

Php Interview Questions and Answers – Part 8

Php Interview Questions and Answers




Php Interview Questions and Answers – Part 8 1- Give the syntax of REVOKE commands? The generic syntax for revoke is as following REVOKE [rights] on [database] FROM [username@hostname] Now rights can be: a) ALL privileges b) Combination of CREATE, DROP, SELECT, INSERT, UPDATE and DELETE etc. We can grant rights on all database by using *.* or some specific database by database.* or a specific table by database.table_name. 2- What is the difference between CHAR and VARCHAR data types? […]

Convert .xsd file into array in PHP

jpeg




As we know that PHP has no direct function to convert .xsd(XML Schema Definition) file into associative array like XML file. So you have to  first convert .xsd file into xml then finally parse xml file into associative array. Below are few easy steps to convert .xsd file into associative array.   $doc->preserveWhiteSpace = true; $doc->load(‘yourfile.xsd’); Step 2: Save .xsd file as an xml file. $doc->save(‘myxml.xml’); Step 3: Generate xml as a string and removed xsd prefixes. $myxmlfile = file_get_contents(‘myxml.xml’); […]

Php Interview Questions and Answers – Part 6

php-interview-title




1- How can we register the variables into a session? session_register($session_var); $_SESSION[‘var’] = ‘value’; 2- What is the difference between characters �23 and x23? The first one is octal 23, the second is hex 23. With a heredoc syntax, do I get variable substitution inside the heredoc contents? Yes. 3- How can we submit form without a submit button? We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we […]

Php Interview Questions and Answers – Part 5

php3




1- How to reset/destroy a cookie ? Reset a cookie by specifying expire time in the past: Example: setcookie(‘Test’,$i,time()-3600); // already expired time Reset a cookie by specifying its name only Example: setcookie(‘Test’); 2- What types of images that PHP supports ? Using imagetypes() function to find out what types of images are supported in your PHP engine. imagetypes() – Returns the image types supported. This function returns a bit-field corresponding to the image formats supported by the version of […]

PHP Interview Questions and Answers – Part 4

php-interview-questions-answers




1- What is the difference between ereg_replace() and eregi_replace()? eregi_replace() function is identical to ereg_replace() except that it ignores case distinction when matching alphabetic characters. 2- How do I find out the number of parameters passed into function9. ? func_num_args() function returns the number of parameters passed in. 3- If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b? 100, it’s a reference to existing variable. 4- How To […]

Php Interview Questions and Answers – Part 3

php-interview-questions-answers




1- What is the difference between CHAR and VARCHAR data types? CHAR is a fixed length data type. CHAR(n) will take n characters of storage even if you enter less than n characters to that column. For example, “Hello!” will be stored as “Hello! ” in CHAR(10) column. VARCHAR is a variable length data type. VARCHAR(n) will take only the required storage for the actual number of characters entered to that column. For example, “Hello!” will be stored as “Hello!” […]

Wrapping Text in PHP

wrapping text in php




Sometimes we need to wrap text to exactly accommodate a certain width of text or allowing browsers to wrap text whenever required. You can use PHP’s wordwrap() function to wrap a string into new lines when it reaches a specific length. This function limits text display to a particular column size, thereby allowing precise control over how text is rendered on a Web page. By default, wordwrap() wraps strings at column 75 using the standard newline sequence. Below example is […]

Order Editor tep_add_base_ref AJAX ERROR FIX – osCommerce

oscommerce




Fatal error: Call to undefined function tep_add_base_ref() in /home/XXXX/public_html/XXXX/admin/edit_orders_ajax.php on line 1149 For those who have this problem:add below code to admin/include/function/general.php before closing tag ?> function tep_add_base_ref($string) { $i = 0; $output = ”; $n=strlen($string); for ($i=0; $i<$n; $i++) { $char = substr($string, $i, 1); $char5 = substr($string, $i, 5); if ($char5 == ‘src=”‘ ) {$output .= ‘src=”‘ . HTTP_SERVER; $i = $i+4;} else { $output .= $char; } } return $output; } /////////////////////////////////////////// You are done! Thank you […]

Php Interview Questions and Answers – Part 2

job-interview-question




1- Why doesn’t the following code print the newline properly? <?php $str = ‘Hello, there.nHow are you?nThanks for visiting techpreparation’; print $str; ?> Because inside the single quotes the n character is not interpreted as newline, just as a sequence of two characters – and n. 2- Would you initialize your strings with single quotes or double quotes? Since the data inside the single-quoted string is not parsed for variable substitution, it’s always a better idea speed-wise to initialize a […]