# PHP script basics

> Get the basics of running PHP scripts on your hosting account, including permissions, file extensions and PHP versions.

Source: https://helpcenter.ruachost.com/developers/php/php-script-basics/

PHP is a server‑side scripting language that allows you to create dynamic web pages. On **ruachost.com**, PHP is preinstalled on all hosting accounts, making it easy to run scripts without additional setup.

## Key Concepts

### File Permissions

- PHP script files should be set to **755** permissions.
- This ensures the user has read, write, and execute permissions, while the group and world have read and execute permissions.
- Incorrect permissions may cause errors or prevent scripts from running.

### Shebang Header

- Unlike Perl or Python, PHP scripts **do not require a shebang line** (`#!/usr/bin/php`).
- You can run PHP scripts without adding this header.

### Short Tags

- Ruachost servers support PHP short tags.
- Example:

  ```
  <? echo "Hello world"; ?>
  ```
- Equivalent to:

  ```
  <?php echo "Hello world"; ?>
  ```

### Path to PHP Executable

- The absolute path to PHP on Ruachost servers is:

  ```
  /usr/bin/php
  ```
- Since `/usr/bin` is in the default path, you can usually run scripts with:

  ```bash
  php filename.php
  ```

### PHP Versions

- Ruachost supports multiple PHP versions (5.6, 7.1–7.4, 8.0–8.4).
- To check the command‑line version:

  ```bash
  php -v
  ```
- To check the web server version, log in to **cPanel → Software → Select PHP Version**.

### File Extensions

- Default extension: `.php`
- You can define additional extensions (e.g., `.html`) in `.htaccess`:

  ```
  AddHandler application/x-httpd-lsphp .html
  ```

### Safe Mode

- PHP safe mode is **not enabled** on Ruachost servers.
- Safe mode was deprecated in PHP 5.3 and removed in PHP 5.4.

## Example Script

```
<?php
echo "Welcome to Ruachost!";
?>
```
