AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old Jul 2, 2007, 08:56  
Младенец
 
Join Date: Jun 2007
Location: Yerevan
Posts: 9
Rep Power: 0
Reputation: 10
PHP Class Define

Barev dzez hargeli forumi masnakicner, Programmerner!!!

Unem mi harc Class - eri veraberyal, shat shnorhakal klinem lselu xorhurdner, ognutyan kargov.

Unenq Class - class.php - um
############################
class.php

class user() {
var $usr;

function set_username ($name) {
$this->usr=$name;
} // end function

function get_username () {
return $this->usr;
} // end function

} // end class
#############################

unenq naev index.php, vortex haytararum enq object

index.php
#############################

require("class.php");
$u=new user();
$u->set_username ('Armen');
echo $u->get_username();

#############################

ays amen@ haskanali e... bayts inchpes kareli e ogtvel classi objectneric mek ayl php fileum, orinak patkeracnenq vor ays index.php fileum classi $usr object@ stanum e arjeq... bayts ayd arjeq@ mez petq e naev myus fileum.. asenq other.php - um.

Naxapes shnorhakalutyun!
kernel is offline   Reply With Quote Quote selected
Old Jul 3, 2007, 20:23   #16
Младенец
 
Join Date: Jun 2007
Location: Yerevan
Posts: 9
Rep Power: 0
Reputation: 10
Dorogie druzia!!! Vo pervix ya ochen rad za vashi otzivi na moy vopros!!!
napisav sessiu ya imel v vedu vremya raboti scripta a ne doslovno session();
(sam vinovat)
u menya class user(), kotori proveryaet dannie pered registracii usera, registriruet usera v db, vozvroshchaet dannie iz db o uzere, skajem tak -
############## Class.php ################################################## ###
class user() {
var $user;
.......
var $xxx;
function set_user($val) {
if (xxxxxxxxx) {
$this->user=$val;
} // end func
function get_user() {
return $this->$user;
} // end func
function register_user() {
insert into xxxx (xxxx, xxx) valuess ($this->user, $this->xxx);
} // end func
function get_user_from_db() {
return select from xxx where user = $this->user;
} // end func
} // end class
}
################################################## #######################
princip raboti klassa ya dumayu ponyaten.
prodoljim...
skajem v file e register.php ya pishu kod
include("class.php");
$u=new user();
if ($u->set_user('David')) {
$u->register_user();
} // end if
eto toje yastnenko...
prodoljem...
u menya v klasse uje presvoen $user, i vsyakoe info.
teper v perexode iz register.php na skajem yourinfo.php mne nujen $u->get_user() ile je $u->get_user_from_db();
po skolku u uzera mnogo infi, vso eto ya xochu toskat' so scriptom vo vremya raboti sitea.
I ne xochu pre kajdoy otkritii novogo *.php filea presvoivat' zanova znachenie objektov klassa user().
povtaryayu class user() imeet mnogo objectov, kotorie ne po ume vsyaki raz presvoivat'. tut ya tolko opisal user name i togdaleee...
nu mojet est' variant skajem pre pomoshchi get ile set otpravit username, i togda obyaviv klass zanova poluchit vse info s pomoshchu
set_user('david');
get_xxx_from_db()
get_yyy_from_db(); i. t. p.
Odnako mojet ya ne prav... etot klass mojet i ne pravilno stroen?
i voopshe chto vi skajete po povodu etogo klassa, i k obrashcheniu k nemu v raznix php fileax?
(izvenite menya za slishkom negramotni russki yazik)
Sposiba vsem za pomoshch i vnimanie!!!
kernel is offline   Reply With Quote Quote selected
Old Jul 3, 2007, 20:35   #17
Младенец
 
Join Date: Jun 2007
Location: Yerevan
Posts: 9
Rep Power: 0
Reputation: 10
ist i eshcho odin variant, v klasse user() mogu pisat funckciu v rode kak konstruktor, skajem
$u->set_user('david');
$u->construct_from_db();
#### class ####
function construct_from_db() {
select * from users where username = '$this->user';
$this->phone=mysql_XXXXXXXXX
.........
$this->address=mysql_xxxxxxx
} // i togda ya mogu poluchit vse get_xxx() i.
############

a mojet i eto slishkom kustari variant
kernel is offline   Reply With Quote Quote selected
Old Jul 4, 2007, 03:02   #18
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 4
Reputation: 12
Send a message via ICQ to Intel
Quote:
Originally Posted by kernel
vso eto ya xochu toskat' so scriptom vo vremya raboti sitea.
Это невозможно: PHP скрипт это не Web Application, он начинает работать каждый раз, когда его вызывают и заканчивает работу.
Для сохранения состояния предусмотрены session и cookie, а не об'екты которые могут "жить" на протяжении жизни Web Application-а, как в JSP/ASP.NET.
В PHP обычно при каждом request-е информацию берут заново(к примеру этот форум).
Intel is offline   Reply With Quote Quote selected
Old Jul 4, 2007, 11:14   #19
Младенец
 
Join Date: Jun 2007
Location: Yerevan
Posts: 9
Rep Power: 0
Reputation: 10
Hargeli barekamner shat shnorhakal em boloric!!! Duq indz tveciq shat chisht xorhurdner!!!ayjm kporcem ashxatel singletoni mijocov, vor@ karcum em bavarar klini nman ashxatanqi hamar.
kernel is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The C++ programmer's "wedding" ByTheWay Fun 2 Nov 12, 2006 07:31
PHP 4.4.0 Problem... Mesrop Languages, Compilers and Interpreters 24 Nov 9, 2005 09:37
Help!Help!help! Awful Unix 56 Sep 21, 2005 12:32
PHP against ASP acid Web Development 1 Aug 6, 2004 21:30
PHP remote vulnerabilities VX Software Security 0 Mar 4, 2002 19:20


All times are GMT. The time now is 03:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link