PHP General Questions & Answers
Reblogged from Web Development:
Question1: What are the differences between require and include, include_once?
Answer:
File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
The major difference between include() and require() is that in failure include() produces a warning message whereas require() produces a fatal errors.
Arrays of arrays in PHP
Reblogged from C 2 Java 2 Php:
I love how quick and easy it is in PHP to declare complex data structures of associative arrays within arrays within arrays.
Consider the array below that starts with string prompt:
32 var $arrFilters = array( 33 '0' => array( 34 'strPrompt' => 'Preset Reports...', 35 ), 36 '1' => array( 37 'strPrompt' => 'Email Opens', 38 'FILTER_1' => array( 39 'strValue' => 'email', 40 'strFind' => 'exact', 41 'strColumn' => FILTER_COLUMN_HOW, 42 ), 43 ), 44 );
The Quest for Quote Consistency
Reblogged from C 2 Java 2 Php:
Double quotes or single quotes? That is the question.
After running down a problem with JSON being passed in a hidden field of HTML begin generated by PHP, I've come to a new (to me) coding rule for which type of quote to start out using:
- Double quotes by default for server code (e.g. PHP) and data exchange (e.g. JSON).
Setup PHPcassa
Reblogged from Cassandra Hands-on:
phpcassa is a PHP client library for Apache Cassandra.
- Compatible with Cassandra 0.7, 0.8, 1.0, and 1.1
- Optional C extension for improved performance
phpcassa is compatible with PHP 5.3+
phpcassa is open source under the MIT license.
You can download it from here
Choosing an IDE
What is an IDE?
- IDE means Integrated Development Environment.
- It provides certain facilities which helps a programmer for software development.
- They are designed in a such a way so that it can maximise the developer productivity.
- There are many IDE's which support multiple programming languages.
There are lots of IDE's are available today. Even though some of them are not free, there are lot of IDE's which are free.
PHP Syntax
The syntax for php is shown below. It starts with the opening tag
and ends with the closing tag
In between we will write our code.
A php file will be having the extension .php. HTML's can be also embedded into a php file. Php scripts are executed on the server and the results are displayed on the web broswer ie firefox or chrome.
