SAPI Differences PHP configuration
PHP is not only available for many different operating systems, but it also offers native interfaces to a range of different Server APIs, or SAPIs in PHP lingo. The most common PHP SAPI is the Apache 1.3 module; others are CGI, CLI, the IIS filter, the embeddable version of PHP,and so on.
Some SAPIs offer PHP functions that are available only in that SAPI.
For example, the Apache 1.3 SAPI offers a function called apache_note() to
pass information to other Apache modules.
Table below shows some SAPI-specific functions.
| Function | SAPI Layers that Define It |
| ApacheRequest (class) | apache_hooks |
| apache_lookup_uri | apache, apache_hooks, apache2filter |
| apache_request_headers | apache, apache_hooks, apache2filter |
| apache_response_headers | apache, apache_hooks, apache2filter |
- Kiran's blog
- Add new comment
- Read more
- 307 reads
DB Error Codes
Each database driver converts the error codes or error messages from the DBMS to a DB error code. These codes are represented as PHP constants. Here is a list of supported error codes given by examples of situations that causes them:
☞ DB_ERROR_ACCESS_VIOLATION. Missing privileges for a table, no read access
to file referenced by opaque parameters, or bad username or password.
☞ DB_ERROR_ALREADY_EXISTS. Table, sequence, procedure, view, trigger, or some
other condition already exists.
☞ DB_ERROR_CANNOT_CREATE. Cannot create table or file; the cause of problem
is outside the DBMS.
☞ DB_ERROR_CANNOT_DROP. Cannot drop table or delete file; the cause of problem
is outside the DBMS.
☞ DB_ERROR_CONNECT_FAILED. Could not establish database connection.
☞ DB_ERROR_CONSTRAINT. Foreign key does not exist, row contains foreign key
referenced by another table, and field constraints violated.
☞ DB_ERROR_CONSTRAINT_NOT_NULL. Field may not be NULL.
- Kiran's blog
- Add new comment
- Read more
- 300 reads
Understanding MIME type
MIME stands for "Multimedia Internet Mail Extensions." MIME was originally invented for describing the content of email.
"MIME types" are generally used for identifying the type of information in a file. While the file extension .htm is not formally understood to mean that the file is an HTML page, there is no requirement that it mean this, and many HTML pages have different file extensions.
In case of HTTP protocol used in web browsers for communicating with web servers, the "file extension" of the URL are really not used to determine the type of information that the server will return. In some cases, there may be no file extension at all at the end of the URL.
So the web server in terms specifies the correct MIME type using a Content-type: header while responding to the web browser's HTTP request.
Some common MIME type are as follows:
| Type | Common File Extension | Purpose |
|---|
- Kiran's blog
- Add new comment
- Read more
- 325 reads
Session Concept PHP
HTTP being a stateless protocol - every request that comes from a browser to the server cant be identified by the server as a subsequent request of that user/IP/browser or a complete new request.
HTTP doesn't really understand who had made request. In such cases sessions manage to make HTTP look intelligent? The Answer lies in the request-response model with data.
Generall when a normal request is made to server the minimalistic data passed by the client/browser is this
GET / HTTP/1.1
Host: kiran.org.in
The server responds by giving the output. But however, when we do session_start();, What actually happens is, the PHP engine sets a PHPSESSID cookie. This data is sent from the Server as Set-Cookie header. So the response goes somewhat like this
Date: xxxx
Set-Cookie: PHPSESSID=<32charhexvalue>; expires=xxxx
...
- Kiran's blog
- Add new comment
- Read more
- 515 reads
The Heredoc Syntax PHP
Heredoc, in case you’ve never heard the term before, is an alternative way for encapsulating strings. It’s used and seen much less often than the standard single or double quotes, but it fulfills the same role. Heredoc is like putting peanut butter on bananas: you either grow up doing it or you don’t. The heredoc
method works just like a double quote in that the values of variables will be printed, but you can define your own delimiter, which is particularly nice when printing oodles of HTML (with its own double-quotation marks).
The only catch to heredoc is that its syntax is very particular!
The heredoc syntax starts with <<<, immediately followed by an identifier. The identifier is normally a word in all caps. It can only contain alphanumeric characters plus the underscore (no spaces), and it cannot begin with a number. There should be nothing on the same line after the initial identifier, not even a space! So usage of heredoc might begin like
echo <<
- Kiran's blog
- Add new comment
- Read more
- 638 reads













