-6

I know this is probably a noob question but I really can't figure this out.

I was ask to modify the existing php code so I downloaded the code and try running on my machine but i can't get it to work.

from my understand we write php code in

<?php
//some code
?>

but this code that i downloaded uses php code like this

<?
//some code
?>

It doesn't work on my machine but it works on the production server.

Does anyone know how this works?

Update:

Looking at the code in details, this is example of the code

<?php include $_SERVER["DOCUMENT_ROOT"]."/pages/layouts/summary.php";  ?>

then in summary.php

<?
session_start();
require_once $_SERVER["DOCUMENT_ROOT"]."/includes/mysql.php"; 
require_once $_SERVER["DOCUMENT_ROOT"]."/includes/functions.php"; 
//more code ...
?>
Raver0124
  • 512
  • 2
  • 9

3 Answers3

5

When PHP parses a file, it looks for opening and closing tags, which are <?php and ?> which tell PHP to start and stop interpreting the code between them. Parsing in this manner allows PHP to be embedded in all sorts of different documents, as everything outside of a pair of opening and closing tags is ignored by the PHP parser.

PHP also allows for short tags <? and ?> (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option.

Read here http://php.net/manual/en/language.basic-syntax.phptags.php

R R
  • 2,999
  • 2
  • 24
  • 42
  • Thank you soooo much, that make sense now. Answer has been accepted :) the site still throwing some error but it's something else. Is there anyway to turn off the Notice message? (undefined variable warning message) – Raver0124 Nov 13 '13 at 07:47
  • i have to wait 3 more min to accept your answer :( – Raver0124 Nov 13 '13 at 07:47
  • @Raver0124 i am happy my answer was helpful to you.:) – R R Nov 13 '13 at 07:52
2
; http://php.net/short-open-tag
short_open_tag = Off

Open short tag from php.ini file

 short_open_tag = on
Kamal
  • 796
  • 7
  • 11
0

if short_open_tag is set to on in the php.ini file then we can use instead of but its madatory to use if short_open_tags are set to off in the php.ini file.This is off on default

praveen
  • 286
  • 1
  • 8