PHP

 Snippets for Drupal:

Print node fields to screen:

<pre>
<?php print_r($node) ?>
</pre>

Print Node Body:

 

<?php print $node->content['body']['#value']; ?>

 

<?php print="">

<?php print=""><?php>

Commands

var_dump

var_dump displays structured information about one or more expressions that including its type and value.  A recursive listing is created for Arrays and Objects, with values indented to show structure.

Public, private and protected Object properties are returned in the output.

Figure out Apache/PHP user names

When setting security permissions in Linux, it may be important to figure out the name of the Apache and PHP users.  Often they are the same.  To find the name of the Apache user, issue the command:

ps -ef | grep apache

To determine the name of the PHP user, create and execute a PHP script with the following code:

<?php echo posix_getuid();?>
 

Figure out php.ini location

Where is php.ini?

From the Linux command line:

To determine the location of php.ini, run the following (Linux only):

php -r "phpinfo();" | grep Configuration

 

 

From Drupal:

The easiest way is to install the Devel Module, which has an option to run PHPinfo() and display the results in the browser.

PHP Ini Settings

The default PHP timeout in php.ini is 30 seconds, which is too short for some Drupal activities like listing/enabling modules.

SVN

Commonly Used Command

snv info - status of current directory if it is a working copy

svn commit - commit changes to repository

svn update - update working copy with latest changes from repository