Category Archives: PHP

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 […]

8 SEO Tips For Facebook Graph Search

seo




Facebook Graph Search has a huge database – One billion people, more than 240 billion photos and a trillion connections. To tap this traffic gold mine with your Facebook page, it has to be SEO optimized. It has to emits the necessary signals for maximum visibility in Facebook Graph search. Definition: A Facebook Search Engine which returns the best possible suggestions (search results) when people search for things and relationships they care about. Web search Vs. Facebook Search: When you […]

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 Security

script-secuity




When it comes to PHP, some 99% of amateur sites and 60-70% of all sites use the professional scripting language called PHP. But is it safe to use PHP? Does the implementation of the language not have any gaps that are critical to the operation of our applications? But remember that security problems do not arise just from the language itself, but also from the programming skills of those who write PHP scripts. Of course, most of the errors can […]

Long Tail Keywords Benefits

long-tail-keywords




Long tail keywords targeting or optimization has greater benefits than its counterpart broad ones or head-terms. Long tail keywords search constitutes 70% of total search performed on major search engines like Google, Yahoo and Bing, and the so called head-terms the rest 30%. Even a trend of ultra-long tail keywords optimization has emerged in recent times due to various advantages it offers. Getting on the first page of Google for a long tail keyword is much easier than a broad […]

Create Database and Tables in PHP MySQL

php-mysql




As We know database holds one or multiple tables. Here in this post you will learn how create database tables in Mysql Create a Database We use the CREATE DATABASE statement to create a database in MySQL. Syntax CREATE DATABASE database_name To get PHP to execute the MYSQL statement we must use the mysql_query() function. This function is used to send a query or command to a MySQL connection. For Example The following example creates a database called “school_database”: <?php […]

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 […]

Use Multiple Headers in a PHP

php5




With PHP, you can send multiple HTTP headers with file_get_contents() . you can also send information such as HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, and HTTP_CONNECTION with file_get_contents(). In this post, I have write a complete example code to set multiple headers; an Authorization header and a Content-Type header using PHP and make POST request using file_get_contents(). <?php $options = [“http” => [ “method” => “POST”, “header” => [“Authorization: token ” . $access_token, “Content-Type: application/json”], “content” => $data ]]; $context = stream_context_create($options); ?> Now […]

Rename Product Image in SQL Query Oscommerce

oscommerce




How to Rename Product Image in SQL Query in osCommerce. In Oscommerce it is simple to rename the product image in sql query. IN the below is the simple script to sove this require(‘includes/application_top.php’);  $products_query = tep_db_query(“select * from products”);  while ($products_values = tep_db_fetch_array($products_query)) {   $products_id = $products_values[‘products_id’]; $products_image = $products_values[‘products_image’]; $image = $products_image.’.jpg’; //echo $image; //echo $products_id; //echo $products_image; $sql = “update products set products_image = ‘” .$image .”‘ where products_id = ‘” . (int)$products_id . “‘”; $update_query […]