#### Ne Öğreneceğim? - OOP Nedir? - OOP Sınıf Yapısı - OOP Metotları #### Gereksinimler - PHP - Linux #### Zorluk - Orta Düzey  #### Eğitim İçeriği PHP yazılım dili, tüm programlama dillerinde olduğu üzere nesne yönelimli programlamayı desteklemektedir. Geliştirilmek istenen yazılımı kısaltmak ve dizgesel hale getirmek için çok önemli ve çok sık kullanılan bir yöntemdir. PHP4 versiyonunda nesne yönelimli yazılımın temelleri oluşturulduğundan eksikler çok fazlaydı ve PHP5 sürümüyle birlikte eksiklikler giderilerek OOP yapısı tekrar oluşturuldu. PHP5 sürümünden itibaren görünürlük, derslik soyutlama, final anahtar sözcüğü, büyülü yöntemler, nesne arayüzleri, nesne kopyalama ve tür dayatma gibi mevzular eklendi. #### OOP Nedir? OOP, Object Oriented Programming kelimesinin baş harflerinden oluşan bir programlama yöntemidir. Türkçe karşılığı nesne yönelimli programlama olarak ifade edilebilir. OOP, birbiri ile alakalı ve dizgesel olarak çalışabilecek kod parçalarını bir arada tutarak, yazılımın bir tüm olarak çalışmasını sağlar. OOP mimarisi ile geliştirilecek sistem parçalara ayrılarak, parçalar arasında illişki kurmaya olanak sağlar. #### Temel Kavramlar Nesneler, kendi içerisinde tanımlanan değişken ve ek fonksiyonlardan oluşur. Bir nesne içinde tanımlanan birime **özellik**, nesneye ait fonksiyonlara ise **davranış** yada **metod** adı verilir. Dersliğin üyesi olarak ifade edildiğinde ise bu özellik veya metod olabilir. #### Sınıf Yapısı Bir derslik oluşturmak için öncelikle sınıf üyelerinin (özellik ve metotlar) birbiri ile ilişkili olmasına dikkat edilir. Sınıfın yapısı gereği, eğer birbirinden bağımsız özellik ve metotlar kullanırsanız, aslına bakarsanız derslik yazmanın bir anlamı kalmaz. ```php <?php class ilkSinif { #özellik public $birOzellik; #davranis public function birDavranis() { echo 'Davranis Calisti'; } } ?> ``` Yukarıdaki sınıf örneğinde, sınıf **ilkSinif** ismiyle oluşturulmuştur. Sınıf içinde **birOzellik** ismiyle değişken ve **birDavranis** ismiyle metod tanımlanmıştır. #### Sınıf Çağırma (Örnekleme) Bir dersliği çarpıtmak için **new** anahtar sözcüğü kullanılır. Aslında sınıfların bir çeşit veri türü bulunduğunu düşünürsek, çağırdığımız derslik tipinde bir değişken tanımlıyoruz diyebiliriz. ```php <?php $nesne = new ilkSinif(); ?> ``` Yukarıda yer edinen kodları dersliğin hemen altına yazarak tanımladığınız sınıftan bir örnek alabilirsiniz. Sınıftan örnek aldıktan sonrasında erişim izni olan özellik ve metotları kullanabiliriz. Derslik özellikleri **$isim** olarak tanımlansa da bu özelliği dışarıdan kullanırken **$nesne->$isim** olarak değil, **$nesne->isim** olarak kullanmanız gerekmektedir. ```php <?php $nesne = new ilkSinif(); $nesne->isim = 'Ali'; echo $nesne->utopian(); ?> ``` Yukarıdaki örnekte değişkenin içinde tanımlanan isim özelliğine **Ali** değeri yükleniyor ve yine değişken için erişim iznimiz olan **utopian** adlı metodu çalıştırıyoruz. #### Kurucu ve Yıkıcı Metotlar Bir derslik örneklendiğinde İlk olarak çalışan metod kurucu (construct) metodlardır. Sınıf üzerinde aslabir işlem yapmasanız dahil, örnek almış olduğunız anda bu metod otomatik olarak çalışır. Aynı şekilde derslik ile olan bağlantınız sonlandığında ise, yıkıcı (destruct) metodu otomatikman çalışır. Kurucu ve yıkısı metotların nasıl tanımlandığını öğrenmek ve bir sınıftan örnek alındığında otomatik olarak çalışmış olduğunı anlamak için aşağıdaki örneği inceleyip çalıştırarak deneyebilirsiniz. ```php <?php class ilkSinif { #kurucu fonksiyon function __construct() { echo 'Kurucu fonksiyon çalıştı.'; } #yıkıcı fonksiyon function __destruct() { echo 'Yıkıcı fonksiyon çalıştı'; } } #nesne örnekleme $nesne = new ilkSinif(); ?> ``` Yukarıdaki örnek dersliği yazıp çalıştırdığınızda kruucu fonksiyon çalışacaktır. Eğer bu sınıf üzerinde işlem gerçekleştirmiş olsaydık, bu işlemler gerçekleştirilecek ve PHP yorumlayıcısı artık dersliğin kullanılmadığını anladığında yıkıcı fonksiyonu çalıştıracaktı. Kurucu metotlar; çoğu zaman derslik çapırıldığı esnada, sınıfa ilişkin özelliklerin için ilk değerler yüklenir ve lüzumlu görülürse, bazı metotlar tetiklenerek çalıştırılır. Yıkıcı metotlar ise, derslik kullanımını sonlandığinde özelliklerin silinmesi ve yine ihtiyaç halinde bazı metotların çalıştırılması için kullanılabilir. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@sedatyildiz/php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | sedatyildiz | ||||||
---|---|---|---|---|---|---|---|
permlink | php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":1903522,"name":"php-src","full_name":"php/php-src","html_url":"https://github.com/php/php-src","fork":false,"owner":{"login":"php"}},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","tr","php","oop"],"users":["sedatyildiz"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1517508483/ij9agrve8i9qmjszhb5r.png"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1517508483/ij9agrve8i9qmjszhb5r.png"],"moderator":{"account":"deathwing","time":"2018-02-04T03:45:47.159Z","flagged":false,"reviewed":true,"pending":false}} | ||||||
created | 2018-02-01 18:08:18 | ||||||
last_update | 2018-02-04 03:45:45 | ||||||
depth | 0 | ||||||
children | 11 | ||||||
last_payout | 2018-02-08 18:08:18 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 11.268 HBD | ||||||
curator_payout_value | 4.664 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 4,682 | ||||||
author_reputation | 4,535,285,897,770 | ||||||
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 34,190,975 | ||||||
net_rshares | 3,187,678,576,711 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
cheetah | 0 | 2,274,709,185 | 0.08% | ||
nickfost | 0 | 776,735,974 | 1.6% | ||
renzoarg | 0 | 3,079,455,789 | 1.6% | ||
dexter-k | 0 | 2,826,336,799 | 1.6% | ||
anomaly | 0 | 229,518,757 | 1% | ||
veteran | 0 | 54,308,228 | 100% | ||
coolenglish | 0 | 2,863,527,078 | 1.6% | ||
flypanda | 0 | 12,070,036,037 | 100% | ||
businesswri | 0 | 444,910,632 | 1.6% | ||
detlev | 0 | 965,084,475 | 1.6% | ||
acwood | 0 | 1,510,749,095 | 1.6% | ||
suggeelson | 0 | 168,266,346 | 1.6% | ||
staticinstance | 0 | 40,951,946,046 | 1.6% | ||
arunava | 0 | 6,276,891,007 | 1.6% | ||
mxzn | 0 | 1,027,907,827 | 1.6% | ||
alphacore | 0 | 577,482,414 | 1.3% | ||
xtetrahedron | 0 | 1,088,501,933 | 1.6% | ||
imransoudagar | 0 | 1,212,775,058 | 1.6% | ||
jonbit | 0 | 1,051,528,153 | 1.6% | ||
technerd888 | 0 | 1,545,492,093 | 1.6% | ||
bigdeej | 0 | 6,252,521,607 | 1.3% | ||
gazur | 0 | 1,355,889,754 | 1.6% | ||
cifer | 0 | 3,378,582,641 | 90% | ||
larrydavid4 | 0 | 1,819,370,364 | 1.6% | ||
grandpawhale | 0 | 83,680,840,649 | 1.6% | ||
funkie68 | 0 | 2,825,512,624 | 1.6% | ||
chudilo | 0 | 52,666,968 | 100% | ||
zeeshan003 | 0 | 1,867,497,330 | 1.6% | ||
intuitivejakob | 0 | 601,099,129 | 1.6% | ||
zord189 | 0 | 890,646,667 | 1.6% | ||
coolguy123 | 0 | 17,111,112,520 | 6% | ||
utopian-io | 0 | 2,967,301,230,328 | 1.97% | ||
tradingbroom | 0 | 1,159,642,542 | 1.6% | ||
zoltarian | 0 | 1,333,207,465 | 1.6% | ||
aghunter | 0 | 3,871,451,741 | 1.6% | ||
matematikciemre | 0 | 1,769,727,451 | 100% | ||
herrleger | 0 | 52,574,157 | 1.6% | ||
exposez | 0 | 4,079,707,561 | 1.6% | ||
cryptoconnector | 0 | 1,407,384,278 | 1.6% | ||
regenin | 0 | 825,872,446 | 100% | ||
amicus | 0 | 1,352,464,509 | 1.6% | ||
bedis | 0 | 614,240,674 | 100% | ||
timmylace | 0 | 1,140,472,995 | 1.6% | ||
caps | 0 | 67,721,329 | 100% | ||
claraquarius | 0 | 1,870,976,056 | 5% |
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in: https://www.orhanbhr.com/sinif-cagirma-ornekleme-oop/
author | cheetah |
---|---|
permlink | cheetah-re-sedatyildizphp-ile-siniflar-ve-nesne-yoenelimli-programlama-oop |
category | utopian-io |
json_metadata | "" |
created | 2018-02-01 18:08:30 |
last_update | 2018-02-01 18:08:30 |
depth | 1 |
children | 1 |
last_payout | 2018-02-08 18:08:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 152 |
author_reputation | 942,693,160,055,713 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,191,009 |
net_rshares | 0 |
Thank you. It's good to see this.
author | sedatyildiz |
---|---|
permlink | re-cheetah-cheetah-re-sedatyildizphp-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180201t182441259z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-01 18:24:42 |
last_update | 2018-02-01 19:05:39 |
depth | 2 |
children | 0 |
last_payout | 2018-02-08 18:24:42 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 33 |
author_reputation | 4,535,285,897,770 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,194,165 |
net_rshares | 0 |
Thank you for the contribution. It has been approved. You can contact us on [Discord](https://discord.gg/uTyJkNm). **[[utopian-moderator]](https://utopian.io/moderators)**
author | deathwing |
---|---|
permlink | re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180204t034551499z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-04 03:45:48 |
last_update | 2018-02-04 03:45:48 |
depth | 1 |
children | 2 |
last_payout | 2018-02-11 03:45:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 1.190 HBD |
curator_payout_value | 0.396 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 172 |
author_reputation | 269,077,595,754,009 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,792,129 |
net_rshares | 234,316,486,782 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
utopian.tip | 0 | 234,316,486,782 | 19.3% |
Thank you.
author | sedatyildiz |
---|---|
permlink | re-deathwing-re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180204t050442484z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-04 05:04:45 |
last_update | 2018-02-04 05:04:45 |
depth | 2 |
children | 0 |
last_payout | 2018-02-11 05:04:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 10 |
author_reputation | 4,535,285,897,770 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,804,381 |
net_rshares | 0 |
Hey @deathwing, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
author | utopian.tip |
---|---|
permlink | re-re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180204t034551499z-20180204t060419 |
category | utopian-io |
json_metadata | "" |
created | 2018-02-04 06:04:21 |
last_update | 2018-02-04 06:04:21 |
depth | 2 |
children | 0 |
last_payout | 2018-02-11 06:04:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 159 |
author_reputation | 238,310,597,885 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,813,796 |
net_rshares | 0 |
Nevermind
author | howo |
---|---|
permlink | re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180202t172830332z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"steemit/0.1"} |
created | 2018-02-02 17:28:12 |
last_update | 2018-02-02 19:24:21 |
depth | 1 |
children | 4 |
last_payout | 2018-02-09 17:28:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 9 |
author_reputation | 515,737,941,459,006 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,449,169 |
net_rshares | 0 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
remoteman | 0 | 0 | 0% |
However, the rule has been shared before committing. So it must be valid!
author | remoteman |
---|---|
permlink | re-howo-re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180202t173422968z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-02 17:34:30 |
last_update | 2018-02-02 17:34:30 |
depth | 2 |
children | 3 |
last_payout | 2018-02-09 17:34:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 73 |
author_reputation | 260,206,479,074 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,450,292 |
net_rshares | 0 |
No, rule change was 2 days ago : https://steemit.com/utopian-io/@utopian-io/utopian-rules-update-8-dropped-crowdin-support-english-only-and-more He wrote this yesterday, hence he wrote an article that was not in accordance with the rules when publishing his contribution.
author | howo |
---|---|
permlink | re-remoteman-re-howo-re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180202t175145668z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://steemit.com/utopian-io/@utopian-io/utopian-rules-update-8-dropped-crowdin-support-english-only-and-more"],"app":"steemit/0.1"} |
created | 2018-02-02 17:51:27 |
last_update | 2018-02-02 17:51:27 |
depth | 3 |
children | 2 |
last_payout | 2018-02-09 17:51:27 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 272 |
author_reputation | 515,737,941,459,006 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,453,492 |
net_rshares | 0 |
### Hey @sedatyildiz I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Suggestions - Contribute more often to get higher and higher rewards. I wish to see you often! - Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck! #### Get Noticed! - Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-sedatyildiz-php-ile-siniflar-ve-nesne-yoenelimli-programlama-oop-20180204t194631058z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-04 19:46:30 |
last_update | 2018-02-04 19:46:30 |
depth | 1 |
children | 0 |
last_payout | 2018-02-11 19:46:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,509 |
author_reputation | 152,955,367,999,756 |
root_title | "PHP ile Sınıflar ve Nesne Yönelimli Programlama (OOP)" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 34,964,236 |
net_rshares | 0 |