LAMP How To - Open Source At Work

Only Passion Matters

Entries for the ‘Think PHP’ Category

submitting a form using hyperlinks

If using hyperlink to submit form, remember to return false in “onclick” so that it is backward compatible with IE6, ie
<a class=”button_next” href=”javascript:;” onclick=”$(’#form_wizard’).submit();return false;”>
<span>Update</span>
</a>

resolving jquery conflict with other javascript libraries

It is good to know that jquery can work with other js libraries…
Just need to know how to resolve the conflict
http://api.jquery.com/jQuery.noConflict

php coding standard and tips

It is important that developers follow a certain coding standard to help make the code readable and maintainable. These are what I gathered so far as the best coding practice:
File formatting:
- Never close php tag when using zend framework, ie, “?>”
- Use 4 space indentation as tab spacing. It is possible to configure this in [...]

bash: passing output from one program to another

sometimes you want to be able to pass output from one program to another, say from bash to php. There is a neat trick to do it. In php, we execute the bash script restartapache.
<?php
$command=”/usr/local/bin/restartapache {$_GET['server']}”;
exec($command, $output); foreach ($output as $v)
{ echo “$v <br/>”; }
?>
then in the bash, we write the output to a [...]

PHP: manual install of pear

Sometimes, certain php apps require certain packages to be installed via pear.
Use yum if given a choice, ie “yum install php-pear”.
If yum is not available or due to whatever reason, We need to manually install a new version from pear website.
elinks -source http://pear.php.net/go-pear | php

// follow thru the prompts. then configure the installation parameters

Below is [...]