# Need help with PHP5



## GhettoBSD (Mar 16, 2010)

I'm moving a site from a linux host to a bsd host. Everything is working out except for php!

The page in question worked fine on linux php5.2.8, and bsd php5-5.2.11. But the difference in version has caused some code to not work properly.

The code in question is this:


```
$link_pt1 = '<li';
$link_pt2 = '><a href="';
$link_pt3 = '">';
$link_pt4 = '></a></li>';
```

While on linux host it works great, on bsd it displays:

```
'; $link_pt4 = '>'; $link_01 = home; $link_02 = services; $link_03 = about; $link_04 = contact; $link_05 = espa
```

Everything else is working fine (as far as php is concerned). Any ideas?

PS Sorry DD! ]


----------



## jailed (Mar 16, 2010)

```
';
$link_pt4 = '>';
$link_01 = home;
$link_02 = services;
$link_03 = about;
$link_04 = contact;
$link_05 = espa
```

First, home, services, about and contact are constants in your example.

Constants are used as this:

```
define("home", "Home);
echo home;
```

For strings you must write as,

```
$link = "home";
```

Then, if I'm not wrong, you say that on BSD server server responses the code. If you mean apache, then you must install php module.

What happens when you write [CMD=""]php -f file.php[/CMD] on your console?


----------



## SirDice (Mar 16, 2010)

Did you install PHP5 using a package? If so, the package doesn't contain the apache module. You need to build php5 from the port.


----------



## GhettoBSD (Mar 16, 2010)

Thanks for the replies!

*Jailed:* interesting, php -f header.php returns this:

```
PHP Notice:  Use of undefined constant home - assumed 'home' in /usr/local/www/apache22/website/header.php on line 33
PHP Notice:  Use of undefined constant services - assumed 'services' in /usr/local/www/apache22/website/header.php on line 34
PHP Notice:  Use of undefined constant about - assumed 'about' in /usr/local/www/apache22/website/header.php on line 35
PHP Notice:  Use of undefined constant contact - assumed 'contact' in /usr/local/www/apache22/website/header.php on line 36
PHP Notice:  Use of undefined constant espanol - assumed 'espanol' in /usr/local/www/apache22/website/header.php on line 37
PHP Notice:  Use of undefined constant Home - assumed 'Home' in /usr/local/www/apache22/website/header.php on line 47
PHP Notice:  Use of undefined constant Services - assumed 'Services' in /usr/local/www/apache22/website/header.php on line 48
PHP Notice:  Use of undefined constant Forum - assumed 'Forum' in /usr/local/www/apache22/website/header.php on line 52
PHP Notice:  Use of undefined constant Blog - assumed 'Blog' in /usr/local/www/apache22/website/header.php on line 53
<li><a href="Home.php">Home</a></li>PHP Notice:  Use of undefined constant services - assumed 'services' in /usr/local/www/apache22/website/header.php on line 63
```

So it turns out there is more than 1 error! hahaha oops 

Someone else pointed how nasty the code is and about constants. So I will look into cleaning it up in the future.


*SirDice:* Well I should have probably posted my stats haha

*I started off with:*


```
FreeBSD 8 RELEASE
wordpress: 2.9.2
php5-5.2.11 PHP Scripting Language
php5-mysql-5.2.11 The mysql shared extension for php
mysql-client-5.0.86 Multithreaded SQL database (client)
mysql-server-5.0.86 Multithreaded SQL database (server)
apache-2.2.13 Version 2.2.x of Apache web server with prefork MPM.
```

*And ended up with*

```
FreeBSD 8 release
mysql-client-5.1.39 Multithreaded SQL database (client)
mysql-server-5.1.39 Multithreaded SQL database (server)
php5-5.2.11 PHP Scripting Language
php5-extensions-1.3 A "meta-port" to install PHP extensions
php5-mysql-5.2.11 The mysql shared extension for php
apache-2.2.13 Version 2.2.x of Apache web server with prefork MPM.
```

I also installed all through ports.


The reason it wasn't displaying properly was the difference in php versions. The older version didn't have a problem processing this:


```
<? menu();?>
```

But the newer version did. So I modified it to this:

```
<?php menu(); ?>
```
and it works!

Thanks for your time guys!

Oh and BTW, this was to get wordpress up and running hahaha  But I will look into geeklog as recommended by my buddy!


----------



## roddierod (Mar 17, 2010)

> The reason it wasn't displaying properly was the difference in php versions. The older version didn't have a problem processing this:
> 
> 
> ```
> ...



That not a version problem, that because you had short tags enabled on the Linux machine and not the BSD machine.


----------



## GhettoBSD (Mar 18, 2010)

Hmm, so how can I enable short tags on BSD?

Thanks!


----------



## DutchDaemon (Mar 18, 2010)

/usr/local/etc/php.ini


```
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.  
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = On
```


----------



## GhettoBSD (Mar 18, 2010)

DutchDaemon said:
			
		

> /usr/local/etc/php.ini
> 
> 
> ```
> ...



you the man, thanks!


----------

