Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3224392
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:13:05+00:00 2026-05-17T16:13:05+00:00

I am trying to migrate my site to PHP and use a WP theme

  • 0

I am trying to migrate my site to PHP and use a WP theme on my site with out modifying the theme too much. So my problem is that I want to create a functions.php file like in WordPress that contains some code that can be called to load the header and footer of my sites theme from each page. Also I want to keep some constants in another file that will be used in my site for loading files from my sub-domains, getting the current year, etc. I have a basic get_file() function for loading files from my static content domain, But when I try to run it I get this:

Parse error: syntax error, unexpected T_FUNCTION in /home/s0urc3/public_html/includes/functions.php on line 4

Here are the contents of my functions.php and my constants.php:

functions.php

<?php
include('constants.php')
/*Gets a file from the domain http://files01.s0urc3.ismywebsite.com/*/
function get_file($file)
{
FILE_ROOT + $file
}
get_file(images/bg.jpg)
?>

constants.php

<?php
/* CONSTANTS*/
define(FILE_ROOT, "http://files01.s0urc3.ismywebsite.com/")
define(HOME, "http://s0urc3.ismywebsite.com/")
define(BLOG_HOME, "http://blog.s0urc3.ismywebsite.com/")
define(FORUMS_HOME, "http://forums.s0urc3.ismywebsite.com/")
define(YEAR, getdate(year))
/*define(FILE_ROOT, "http://files01.s0urc3.ismywebsite.com/")*/
?>

Any and all help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:13:06+00:00Added an answer on May 17, 2026 at 4:13 pm

    You have virtually no lines free of syntax errors. You will never get anywhere muddling your way forward this way. Find a tutorial and learn PHP before trying to port your code.

    Specifically:

    In PHP, as in other C-style languages, your statements must end with semicolons:

    // bad; missing semi-colon
    include('constants.php')
    // good:
    include('constants.php');
    

    Your uses of define are wrong. The symbol to define must be passed to define() as a string before it can be used as a symbol:

    // bad; FILE_ROOT not yet defined, missing semi-colon
    define(FILE_ROOT, "http://files01.s0urc3.ismywebsite.com/")
    // good:
    define('FILE_ROOT', "http://files01.s0urc3.ismywebsite.com/");
    

    Strings must be enclosed in either single quotes or double quotes:

    // bad; missing quotes around string, missing semi-colon
    get_file(images/bg.jpg)
    // good:
    get_file('images/bg.jpg');
    

    Values must be explicitly returned from functions via the return keyword, and strings are concatenated using the dot . operator:

    // bad; Perform integer addition, doesn't return, no semi-colon
    FILE_ROOT + $file
    // good:
    return FILE_ROOT . $file;
    

    And a note on style: You’ve commented get_file as ‘getting a file’, which it definitely doesn’t do. All it does is return the fully-qualified URL of the relative URL you pass it. Your function names and comments should strive to clearly tell you what they do. In the case of such a short utility function, I’d go for something very short:

    // Return the fully-qualified URL for the given file
    function url_for($file)
    {
      return FILE_ROOT . $file
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to migrate a site from a joomla system to a drupal. The
I'm trying to migrate django apps, and i have problem with one. When i
I'm trying to migrate CGI scripts to mod_perl using ModPerl::Registry . The scripts use
I am trying to migrate over to Python from Matlab and can't figure out
I am trying to migrate a small ASP.NET 'web site' (not web application) to
I am trying to migrate a content type from a sharepoint site in one
I'm in the process of trying to migrate my ASPNET site to Django. All
I am trying to migrate my site to Drupal and I am confused about
Im trying to migrate the JavaFX 1.3 Magnifying Glass example to JavaFX 2.0 at
I'm trying to migrate from C2DM to GCM, and it mostly works just fine.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.