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 6794395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:13:01+00:00 2026-05-26T18:13:01+00:00

I am using PHP 5.3 on Ubuntu. I want to share a pair of

  • 0

I am using PHP 5.3 on Ubuntu. I want to share a pair of code snippets and want to know the reason of such contradiction in order to initialize associated array.

Case 1: A part of class

class ui_template extends ui\ui_component{
   private $path = __DIR__."/templates";
   private $properties_template = array('path' => __DIR__.'/templates', 'file' => 'mytemplate.php', 'engine' => 'php'); // Parse error: syntax error, unexpected '.', expecting ')'
   private $properties_template = array('path' => $path, 'file' => 'mytemplate.php', 'engine' => 'php'); // Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION

Case 2: A part of simple script

$path = __DIR__ . "/templates";
$temp = new widget\ui_template('new_template');
$temp->extend_template(NULL, array('path' => __DIR__."/templates")); // works fine
$temp->extend_template(NULL, array('path' => $path)); // works fine
  • In the first case at line#3 that is strange to report an error on . while defining path, means concatenation is not allowed there. While in case 2 nothing such error.

  • In the first case at line#4 a variable is also not allowed to initialized path

  • 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-26T18:13:01+00:00Added an answer on May 26, 2026 at 6:13 pm

    You can’t use computed values when declaring class properties. They must be constant (literal string, number, etc.). Docs:

    They are defined by using one of the keywords public, protected, or
    private, followed by a normal variable declaration. This declaration
    may include an initialization, but this initialization must be a
    constant value–that is, it must be able to be evaluated at compile
    time and must not depend on run-time information in order to be
    evaluated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to start using memcache with PHP (on Ubuntu 9.10). There are lots
I want to use PDT to debug PHP with eclipse. I am using ubuntu
I am using Ubuntu 10.10 and i want to install php 5.4 as FPM
I'm using MySQLi with PHP(5.2.4) MySQL(5.0.51a) on Ubuntu 8.04 LAMP. The relevant Db tables
I'm using Eclipse in Ubuntu to edit PHP files. But, unfortunately, some of these
Using PHP, I am trying to delete a record, but I want to check
I am using Symfony 1.3.2 on Ubuntu 9.10 I want to set the default
Background I am writing a simple online judge (a code grading system) using PHP
I have my moodle setup using this guide ( Ubuntu 11.04 ) http://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm I
I run PHP 5.2 on Ubuntu with Apache 2. When I want to serve

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.