CodeIgniter Forums

Full Version: parent construct
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How to fix the error?

Parse error: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php on line 22
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION)
Filename: controllers/Cpages.php
Line Number: 22
Backtrace:


Line 22:    parent::__construct();


controllers/cpages.php


PHP Code:
parent::__construct();
    {    
        
$this->load->helper('url'); //Just for the examples, this is not required thought for the library
    
}    

    
    public function 
index()
    {        
        
$this->load->view('index');
    } 



views/index.php


PHP Code:
<html lang="en">
    <
head>
        <
title>Gionda CMS</title>
        <
meta charset="UTF-8" />
 
       <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <
link rel="stylesheet/less" type="text/css" href="<?php echo base_url(); ?>assets/themes/less/bootstrap.less">
        <
script src="<?php echo base_url(); ?>assets/themes/js/less/less.js" type="text/javascript"></script>
        <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/fullcalendar.css" />    

        <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.main.css" />
        <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.grey.css"/>
        
        <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/add.css"/>
        
    </
head


How to fix the error above?
(05-16-2016, 08:14 AM)davy_yg Wrote: [ -> ]How to fix the error?

Parse error: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php on line 22
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION)
Filename: controllers/Cpages.php
Line Number: 22
Backtrace:


Line 22:    parent::__construct();


controllers/cpages.php


PHP Code:
parent::__construct();
 { 
 
$this->load->helper('url'); //Just for the examples, this is not required thought for the library
 


 
 public function 
index()
 { 
 
$this->load->view('index');
 } 



views/index.php


PHP Code:
<html lang="en">
 <
head>
 <
title>Gionda CMS</title>
 <
meta charset="UTF-8" />
 
       <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <
link rel="stylesheet/less" type="text/css" href="<?php echo base_url(); ?>assets/themes/less/bootstrap.less">
 <
script src="<?php echo base_url(); ?>assets/themes/js/less/less.js" type="text/javascript"></script>
 <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/fullcalendar.css" /> 

 <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.main.css" />
 <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/delta.grey.css"/>
 
 <
link rel="stylesheet" href="<?php echo base_url(); ?>assets/themes/style/add.css"/>
 
 </
head


How to fix the error above?
parent::__construct() no semicolon
Dude, seriously ... this is syntax, entry level. You need to know a lot more than that before trying to work with a framework.
All of your questions here are like this, which irritates people, and you're ignoring all criticism.

To put it in simpler terms - you're trying to write a book, but you can't even spell yet.
PHP Code:
function __construct()
{
    
parent::__construct();
    
$this->load->helper('url'); //Just for the examples, this is not required thought for the library


Now go here and learn PHP before trying to learn a PHP Framework!

PHP NET
PHP is not difficult. I'm also struggled at the beginning, learn from here http://www.w3schools.com/php/
Parse error: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION) in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyProfileCI\application\controllers\Cpages.php on line 22
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected 'parent' (T_STRING), expecting function (T_FUNCTION)
Filename: controllers/Cpages.php
Line Number: 22
Backtrace:


I already erase the semi colons and still dealing with the same error:

http://127.0.0.1/upload/index.php/uploadfile/upload



PHP Code:
parent::__construct()
    {    
        $this
->load->helper('url'); //Just for the examples, this is not required thought for the library
    }     


CodeIgniter File Upload Demo

Select File to Upload
 
The upload path does not appear to be valid.



(I only know CI for 5 months)
function __construct()
{
parent::__construct();
//load here
}
Look at InstiteFx example code more carefully, you are still not doing the class constructor correctly.
(05-16-2016, 03:01 PM)arma7x Wrote: [ -> ]PHP is not difficult. I'm also struggled at the beginning, learn from here http://www.w3schools.com/php/

No! Not w3schools!

Try something like Codecademy:
https://www.codecademy.com/learn/php
(05-16-2016, 05:19 PM)JayAdra Wrote: [ -> ]
(05-16-2016, 03:01 PM)arma7x Wrote: [ -> ]PHP is not difficult. I'm also struggled at the beginning, learn from here http://www.w3scm/phhools.cop/

No! Not w3schools!

Try something like Codecademy:
https://www.codecademy.com/learn/php

w3schools not cover for whole thing about php, but I’m prefer http://php.net/ for documentation and references.
Pages: 1 2