I´m using on my called page two php scripts (avatar.php and items.php). In both of the php datas i have another scripts included like that:
include "../site/api-oauth-master/Client.php"; //
include "../site/api-oauth-master/GrantType/IGrantType.php";
include "../site/api-oauth-master/GrantType/AuthorizationCode.php";
I get now the error:
Fatal error: Cannot declare class OAuth2\Client, because the name is already in use in /www/htdocs/xxxx/site/api-oauth-master/Client.php on line 32
The line 32 of Client.php is:
class Client
{
/**
* Different AUTH method
*/
const AUTH_TYPE_URI = 0;
const AUTH_TYPE_AUTHORIZATION_BASIC = 1;
const AUTH_TYPE_FORM = 2;
Obviusly the problem comes because the Client.php script gets included two times. I thought with "include" this shouldn´t be a problem. Any tips how the scripts can inluded two times on the same page?
Use include_once
or require_once
.
include_once "../site/api-oauth-master/Client.php"; //
include_once "../site/api-oauth-master/GrantType/IGrantType.php";
include_once"../site/api-oauth-master/GrantType/AuthorizationCode.php";