Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 182011
 

Error control operator in PHP

Answer:

The error control operator (the @) is useful to ignore any error messages that might be generated by PHP.

E.g.

<?php

$my_value = @$my_array[$key];

The above statement will not generate any warning even if the index $key doesn't exist.

Mar 162011
 

Render web page using PyQt

Answer:

Qt bindings to WebKit have been added since 4.4, so you can use PyQt to script the browser (Webkit based).

Firstly, make sure you have installed the need packages:

# sudo apt-get install libqt4-core libqt4-webkit python-qt4

Then you can write a simple script to test, e.g.

#!/usr/bin/env python

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *

app = QApplication(sys.argv)

web = QWebView()
web.load(QUrl("http://www.google.com"))
web.show()

sys.exit(app.exec_())
Feb 082011
 

Turn on register_globals in PHP

Answer:

When turned on, register_globals will automatically inject the PHP script with variables such as those from HTML form. The feature was DEPRECATED and turn off by default in the recent PHP distributions.

But if you still want to change it, you need to edit the php.ini

vi /etc/php.ini

Locate and set

register_globals = on;

Remember to restart web server such as Apache if needed.

Feb 062011
 

Change the PHP’s maximum allowed form post size

Answer:

The default maximum allowed form post size in PHP is only 8MB. If you want to change it, you need to edit the php.ini

vi /etc/php.ini

Locate and set (16M in the following example)

memory_limit = 16M;
post_max_size = 16M;

Try it with the number you need.

Also, remember to restart web server such as Apache if needed.