5. php bangla tutorial php basic
DESCRIPTION
mmTRANSCRIPT
����������������������������
AAAA....������� ��� ������� ��� ������� ��� ������� ��� 1. �������
2. �� �� ������
3. ������ Syntax
4. ������� (Variables)
5. ��� (String)
6. ������� (Operators)
7. ������� �����
8. ��� (Loop)
9. While ���
10. For ���
11. ����� (Array)
12. ����� (Function)
13. PHP ��
14. $_GET � !
15. $_POST � !
BBBB....������� �������������� �������������� �������������� �������
• 1111....������� ������� ����������� ������� ������� ����������� ������� ������� ����������� ������� ������� ����������� | | | | ���� � ���� � ���� � ���� � ( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a)( Advanced PHP Tut or i al i n Bangl a) • 2222....������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a) • 3333....������� �489� 1�234 ����������� ������� �489� 1�234 ����������� ������� �489� 1�234 ����������� ������� �489� 1�234 ����������� ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a)( PHP I ncl ude Funct i on Tut or i al i n Bangl a) • 4444....������� ��� ���� 1�234 ������� ��� ���� 1�234 ������� ��� ���� 1�234 ������� ��� ���� 1�234 ( PHP r eq( PHP r eq( PHP r eq( PHP r equi r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a)ui r e Funct i on Tut or i al i n Bangl a) • 5555....������� 1��� 1�234 ����������� ������� 1��� 1�234 ����������� ������� 1��� 1�234 ����������� ������� 1��� 1�234 ����������� ( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a)( PHP Fi l e Funct i on Tut or i al i n Bangl a) • 6666....������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a)( PHP Fi l e Upl oad Tut or i al i n Bangl a) 7777....������� C� ������� C� ������� C� ������� C�
����������� ����������� ����������� ����������� ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a) • 8888....������� 0�34 ����������������� 0�34 ����������������� 0�34 ����������������� 0�34 ����������� ( PHP Sessi on Tut or i al i n Bangl a)� ( PHP Sessi on Tut or i al i n Bangl a)� ( PHP Sessi on Tut or i al i n Bangl a)� ( PHP Sessi on Tut or i al i n Bangl a) • 9999....������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a)( PHP Er r or Handl er Tut or i al i n Bangl a) • 10.10.10.10. ���������������������������� 0���0���0���0��� 1�2341�2341�2341�234 ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a) • 11111111....������� �1O�� ����������� ������� �1O�� ����������� ������� �1O�� ����������� ������� �1O�� ����������� ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)
CCCC....������� 0P�Q�� R������� 0P�Q�� R������� 0P�Q�� R������� 0P�Q�� R
• 1111....������� 0P�Q�� R ����������� ������� 0P�Q�� R ����������� ������� 0P�Q�� R ����������� ������� 0P�Q�� R ����������� | | | | ���� � ���� � ���� � ���� � ( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a)( PHP Fr amewor k Tut or i al i n Bangl a) • 2222....��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a) • [[[[ \���\���\���\��� ��UV��UV��UV��UV ������K��������K��������K��������K�� ���������������������������� ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)
• \��\��\��\��::::^̂̂̂---- ` ` ` ` || || || || \��\��\��\��::::6666---- 10 10 10 10 || || || || \��\��\��\��: 11: 11: 11: 11---- 15 | | 15 | | 15 | | 15 | | \��\��\��\��: 16: 16: 16: 16---- 23232323
• 4444....0 ���a4����� ���4���� �2 �4b� 0 ���a4����� ���4���� �2 �4b� 0 ���a4����� ���4���� �2 �4b� 0 ���a4����� ���4���� �2 �4b� ( CodeI gni t er Downl oad & I nst al l Tut or i al i n ( CodeI gni t er Downl oad & I nst al l Tut or i al i n ( CodeI gni t er Downl oad & I nst al l Tut or i al i n ( CodeI gni t er Downl oad & I nst al l Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a)
• 5. ���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)( MVC St r uct ur e Tut or i al i n Bangl a)
• 6666....0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)
• 7777....0 ���a4����0 ���a4����0 ���a4����0 ���a4����� � Wg� ��h� 34 ij�k � � Wg� ��h� 34 ij�k � � Wg� ��h� 34 ij�k � � Wg� ��h� 34 ij�k ( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )( Cr eat i ng Fi r st Appl i cat i on wi t h CodeI gni t er )
AAAA....������� ��� ������� ��� ������� ��� ������� ��� 1.1.1.1. ������� 0�� ����������� ������� 0�� ����������� ������� 0�� ����������� ������� 0�� ����������� | | | | ���� � ���� � ���� � ���� � ( PHP Basi c)( PHP Basi c)( PHP Basi c)( PHP Basi c)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
��&�'�� &� %�( ��� �� ���! �)�*� �+�� &��� "����:
%��� �)�*� ,�- .�/���� %����� ��� � �0।&�� ,�- ��2� instruction &� �� 3�� run ���� 4$��5$ ���� ��2� ��"
,$।“ ��� ����� ����� ����� �� ���!���!���!���!” ���6 ��7���� ,�- &� �)* (������ �8"���� ��+8��� �� ��$9��� �:�� ��� �� �� handle ���।3��
�8 ��&�'�� #�$� �" ���"� ���� 6�� #�$� ��� �� ��&�'�� ��!(����� ��2� Process ���� 3��:3�� :����� :����(Picture,Content etc) ��� :���� %� 3���� ������� :����(math calculation,file operation etc)6� ������ &��
��; HTML & ����<� ��� �8"���� #�$� =�8"��� ��>���।
��&�'����&�'����&�'����&�'�� (PHP) ��������?:
PHP Hypertext Preprocessor &��� ��� �� ���!,5� ?���� ,HTML-embedded �)�*� ����(��$"।��&�'�� &�
������( syntax (���� C,Perl,Java �� @�� ���।&� ����(��$"A� 8�B�� ,� #�$� �" C6 D6�E ��� !����������। ��&�'����&�'����&�'����&�'�� (PHP) ���������������� %�(%�(%�(%�( �������� "���"���"���"��� ��� ��� ��� ��� :����:����:����:����:
F.HTML .����; ��� HTML Form.
G. C "��� ��� 6�,�� ����@� %�2। H."����)*
� � �1�Q��� W���U4 � � �1�Q��� W���U4 � � �1�Q��� W���U4 � � �1�Q��� W���U4 ?:?:?:?:
3�� #�$� ��� �� ��&�'�� ������ ��� ����� hosting("�$(�) ���6 ,��।& "�� ���� (���6 ,��।& ��;$A ���$ ��� ��I���6
%���'�� ��� ,��। %��66 ���� "�� %��� ���"� ��+8����� #�$� ��� �� ���� ��� ��।& "�� ���J�K ���#$��(��� ���� ���6 ,�� %����
��+8����-
* ��� ����� ����� ����� �� ���#$�����#$�����#$�����#$��
F.&��� PHP -compitable #�$� ��� �� 3��: apache
G.PHP
*L���L���L���L��� ���#$�����#$�����#$�����#$��
F.#�$� =�8"�� 3�� ��"�� ��$���M(&���6� ���� ���� :$�� %�2)
G.&��� �M� &�!�� 3��:������!।%��� ��&�'�� &� "�� Specialized &�!��# ����,�� ���6 �����।��� ��I���6 %��2।
webcoachbd.com &�&�&�&� A8�����$��(���A8�����$��(���A8�����$��(���A8�����$��(��� �N���N���N���N�� %���%���%���%��� �����$�����$�����$�����$ ��&�'����&�'����&�'����&�'�� ����6����6����6����6 ������������������������।।।।
2.
������� �4b��34 ������� �4b��34 ������� �4b��34 ������� �4b��34 ( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a)( PHP I nst al l at i on Tut or i al i n Bangl a) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%�� . � A8�����$��A 6� ��N�2� 6�,�� &�� ��7�6 %� ����� ,����।L��� ���#$��(����6� ���� %�2� &�� ��@� ���� �:�6 ,��#�$� ��� �� 3�� apache &�� ����� ��&�'�� %� &��� !����� ���#$��# ���� �:�$ ��� 3��:MySQL,�� ���" ��(��6� ��� ���2।& ���#$��(��� �� �O ��#$� 3�$।��P$ &6Q�� (�(�� ��' �:�$ ���#$��(��� ��"� ���� ����2�।&��� �," R�����:�- &���� &�� &��� ���#$�� ����� 3�� ���� �:�� ��(��� &������ ���� ,�$ 3���।%� %��:� %��:� ���� ���� �:�6,����।���#$��A ,�- XAMPP.XAMPP &��� �� !�8����! ��� ���� ����
http://www.apachefriends.org/download.php?xampp-win32-1.7.3.exe ������ ���#$�� &� �6 ����
�:�। �S�� ��; !T��� XAMPP &� &�A %��� :���� ����� !��� �L� ��� #��� ���� � �� ������� ���6 �����-3 U�������� �:�$�2� ����� (��� &��� XAMPP Control Panel ���� %��� :��6 ����� � ��n %��� 3�: C U���� ���� :�6�,�� C:\Program Files\xampp �� C:\xampp &� ������� �����। ���� &�� ��@� start ����� click ����(Apache
&�� MySql)।
Apache # MySql '���� �� =�8"���� &U����� ����� http://localhost ��� ���'� �6 &��� �" �����। �� %���
English ����� �L� ����।
&� �"A %��� ��7��� %���� �����6 ��� �� ���� �+V ,�$�2 � ��n %���� ��+8���A &�� ��� �� �,���� ��"���2(����� ��� ��)
3.
������� 0 �� 0 �g�� ��o�4 ������� 0 �� 0 �g�� ��o�4 ������� 0 �� 0 �g�� ��o�4 ������� 0 �� 0 �g�� ��o�4 ( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)( PHP Code Wr i t t i ng)������������ ��������: �"#������"#������"#������"#����� %��%��%��%�� q�r q�r q�r q�r C drive C drive C drive C drive � � � � XAMPP XAMPP XAMPP XAMPP �4b� �r�� g�� 4 j�t�� �� 01�u��� �4b� �r�� g�� 4 j�t�� �� 01�u��� �4b� �r�� g�� 4 j�t�� �� 01�u��� �4b� �r�� g�� 4 j�t�� �� 01�u��� htdocs htdocs htdocs htdocs 4��� ?�� �� 01�u�� ?�v 4��� ?�� �� 01�u�� ?�v 4��� ?�� �� 01�u�� ?�v 4��� ?�� �� 01�u�� ?�v 0�o��4 ?�4�� 0�o��4 ?�4�� 0�o��4 ?�4�� 0�o��4 ?�4�� web content web content web content web content x��� ��o�4।x��� ��o�4।x��� ��o�4।x��� ��o�4।
��� www !W����� ��� !����X�� ,�- “C:\xampp\htdocs”(6�� 3�: ��� U���� ���� �:�� ���� 3��:D drive 6��&�� ,�� “D:\xampp\htdocs”). &�� 3�: &� !����X���6 “mytest.php” ���� ��� ���� ����� 6�,�� %��� &���6������� ��6 ����� &����-=�8"���� &�U����� ����� http://localhost/mytest.php
%-� &��� ��! ��� ���� ��� '���,6�� %�( &��� � � ��! �� �� ������?�������!?����6 ����� 6�� ��&�'�� ��!����� "����2� Y�����"! ���#��� %�2 3��: Net Beans, Dreamweaver �6���: &(�����6 ��! ����� ���� ����@� �����।&(����%� ����� �� ����6 @���� �� �����,3 ����@�(���� �������! ����� ��।&(������ ��� IDE (Integrated Development
Environment).%��� 3���6 ��-�Z���@ ���� ��� ����,�� ����।
4.
������� 0�� �2� j ������� 0�� �2� j ������� 0�� �2� j ������� 0�� �2� j ����������� ����������� ����������� ����������� ( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)( PHP Synt ax Tut or i al i n Bangl a)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
��&�'�� ��! � ��" ����6 ����� ���� extension .php ���6 ,��।3�: .html ��� 6�,�� ��&�'�� ��! execute
,����।
* ��&�'�� ��! &� .�6A ��� <?php �'[ �:�$ ���� &�� ?> �'[ �:�$ �; ,��। * &��� ��&�'�� Scripting Block(<?php &�� ?> &� ��6�� 3� ��� ,$ ��� ���$ &��� \� ) !W����� ��6� ���6
����।
*.�6A %��:� instruction(code line) ����L�� ]��� �; ,��। #�� &��� %���� ��! &�!�� (������!/�U��$��� �� %��� 3� ����,�� ����) ����� &�� ���'� �6 ����� <?php echo"This is my first php page"; ?>
&��� �"A mypage.php ���� �� ����,�� ���� ��$ htdocs browse ��� :���$ �:� save in &� "�$(�$।&���
=�8"���� &�U����� ����� http://localhost/mypage.php &�� &��� �:� ��� ���'� �6 %8���� :��6 �����।
��&�'�� &� %8������ "�� :�A ����� ����^6 ,$ echo # print.
��&�'�� ����������������:��$��� �'[ %�2 3�: ��� ��&�'�� ���!� ����� &(��� �:�$ ����� 6�,�� & ��!(��� %� execute ,����।6����!(��� &�!��� ����, ���� �_� ��$ �� 3�: ����� 6�,�� &�� ���� :�� ��7�6 ������ %��� �� ���6 '�$�2���।&��������� ���� ��� ����6 '���� // �� # %� �,� ������ ���� ��� ����6 '���� ���!� %�( /* &�� ��; */ �'[ ����,�� ���6
,��। ����� : ���� .��A� ����,3�� W �����2� ��� W�।�3�� <?php &�� ?> ���!� ��6�
echo "Hello World! ";echo "Hello World! ";echo "Hello World! ";echo "Hello World! ";echo "Hello World! ";
&�� ����6 �W�। <?php echo "Hello World!"; echo "Hello World!"; ?>
%� ��� ���� :��� ��&�'�� ���!� ��6� Y� ��" �����,&���� .��A� ���� �6� � �6�� �"��� :��6 �����।
5.
������� 0������ ����������� ������� 0������ ����������� ������� 0������ ����������� ������� 0������ ����������� ( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)( PHP Var i abl es Tut or i al i n Bangl a)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
������� ,�- &��� ���`� �6(Container)3���� %��� ���� 6 � ����6 ����।�3�� &��� �MX String “Hello Bangladesh” � �� &��� integer value 100. ��� &��� ������� & &���� 6 � ��� (��� ������� & ��2� ���� &������� ������� declare �� a�;��)��� ����� ��!"��� ������ ����,�� ���6 �����,��� 6 �(value)A ������ �����
�����6 ।��&�'�� 6 ������� “$” &� �'[A �:�$ ����� ���� ���6 ,�� ��,�� ��" ������।
* ������� ��� case sensitive.3�� $a_number and $A_number :�A:�A:�A:�A %��:�%��:�%��:�%��:� �������, ��&�'�� &� :b�c�6। * ���J�K ���� ��&�'�� 6 ������� ��� ,$
$variable_name = Value;
8��� %����'6 ������� (�����6 3�: ��� 6 � ����6 '�� 6�,��- 1.<?php 2.$hello = "Hello World!"; 3.$a_number = 4; 4.$anotherNumber = 8; 5.?>
* ��&�'�� &��� “Loosely Typed” ����(��$" 6�� ������� declare ���� ��$ ������� &� ����(@��) 8�d� �� ����#
��&�'�� ���" �� ������� � �R� !�� ����� ����<� ��� ���। ������� ������ �e�6:
F.����� ��� letter or “_”(under score) �:�$ ���� ���6 ,��।
G. ����� ��@� alpha-numeric characters # underscores. a-z, A-Z, 0-9, or _ . ���6 ����। H. ������� ���� Y� ��� 3�����।3�: ��� &��� ��@� ,$ 6�,�� “___”underscore ($my_string) � �� �N ,��6�
�Q��($myString)����6 ,��।
6.
������� �d2 ����������� ������� �d2 ����������� ������� �d2 ����������� ������� �d2 ����������� ( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)( PHP St r i ng Tut or i al i n Bangl a)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
��&�'�� ��� &6Q� ����,�� ����# (�E� %���'�� ��� ,$��।��&�'�� Career & &� ��� &��� (��f�g� �g ���� ���� ���।6�� & ������� ���h�� @���� ���%����।
��� ����,���� %�( &���� D6�E ��� ���6 ,��।&��� ��� ������ &��� ������ ����,�� ,�6 ���� � �� &��� ������$��� store
���6 ����।���' :��� &�� ��� :���� D6�E ����2,&���� ������$��� store ��� ,�$�2 %������ ������ echo ��� ,�$�2। 1.<?php 2.$my_string = "o merciful make me bold and brave!"; 3.echo " o merciful make me bold and brave!"; 4.echo $my_string; 5.?>
8���� 8:�,��� . � ��� � $my_string ������$��� i� ���$ :$� ,�$�2 %� �]6E$��� %����� ��� � echo ��� ,�$�2,�����������$��� �� store ����।&��� �"��� �� �$ ����6 ,�� 3 3��� ��� ��� � %��� &���@���� ����,���� ?�� ��� ��@� 6���
&���� ����� ������$��� i� ���$ store ��� ����।
%-� &��� 8���� ��!�� W ���� �� ��� ��� ����।=�8"��� ���'� �6 %8���� �����।
&6Q��6� Double quotes ]��� ��� D6�E ��� ,�$�2 &�� Single quotes ]��� ��� D6�E ���6 ����� ��� &��� R�,6�
��,�� %����6� #�� apostrophes ���� ����'6। 1.<?php 2.$my_string = ‘o merciful make me bold and brave!’ ; 3.echo ‘o merciful make me bold and brave!’; 4.echo $my_string; 5.?>
3�: ��� &� ��6� single quotes ����,�� :���� ,$ 6�,�� &���� ����-
echo ‘PHP it\’s neat’
%��� &���� %��66 double quotes ����,�� ��� &�6 ��2� ����@� %�2 3�� single quotes & ���। ��&�'�� ���� 3 �e�6:�A %���'�� ��� ,� & :�A ��@���6 �� .�/���� ����(��$" &� Q�` ����^6 ,$,��j ��&�'�� 6 &�����#$���� � �� � %�2 3�� �:�$ �,������� ��� ��� 3�$ ����� quotation ����,�� ��� 2�N��।���� ,� heredoc,&��� �6� 6����� ��� ���!� ���6 ,�� ��,�� 7����� ,��।���' :��� ������ &�� ���6 ,$- 1.<?php 2.$my_string = <<<TEST 3.He will be succeeded here 4.and here after! 5.TEST; 6.echo $my_string; 7.?>
&���� 3�: ��� ���� 6�,�� ��$�A �"��� ����� �$�� ����6 ,��-
*<<< �� ��2� identifier %�2 3� %����� ����,�� ���6 ,�� heredoc ���� ���� %�( 3�� %�� TEST����,�� ����2।
* ��;# &A ����,�� ����2 &�� ����L�� �:�$ �; ,��।
*&�� ���"� &��� ���� ,��,(indent) ���� ��� ����A ���� ��� 3�����।
%8���� ���'� �6 %��� 3�,6� %��� <br>(������ =� :$�� "�� ����^6 ,$)���( ��� &� ��6� ����,�� �����।
7.
������� ������� ������������������ ������� ������������������ ������� ������������������ ������� �����������( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s)( PHP Oper at or s)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
�������� - ����� �� ������$���� manipulate ���6 ����^6 ,$।H @���� ������� %�2
F.Unary – &��� ����� �� ������$����(operand) ���$ ��" ���।
G.Binary- :�A ����� �� ������$���� �$।
H.Ternary- HA ����� �� ������$���� ���$ ���। &� �������� %��� Operator (������ �������� k�E�e ���6 ���� 3��-Arithmetic, Assignment, Comparison Operator etc.
�����4��K� �����������4��K� �����������4��K� �����������4��K� ������� ( ASSI GNMENT OPERAT� ( ASSI GNMENT OPERAT� ( ASSI GNMENT OPERAT� ( ASSI GNMENT OPERATOR)OR)OR)OR)
& ���������������������������� (���� &��� ����� �� ������$���� ��� &��� ����� �� ������$���� ���� ���6 ���^6 ,$। $my_var = 4;
$another_var = $my_var;
&�� $my_var # $another_var 8��$�� ��� ,� l.
Operator English Example
+ Addition 2+4
- Subtraction 6-2
* Multiplication 5*3
/ Division 15/3
% Modulus 43%10
01.<?php 02.$addition = 2 + 4; 03.$subtraction = 6 - 2; 04.$multiplication = 5 * 3; 05.$division = 15 / 3; 06.$modulus = 5 % 2; 07.echo "Perform addition: 2 + 4 = ".$addition."<br />"; 08.echo "Perform subtraction: 6 - 2 = ".$subtraction."<br / >"; 09.echo "Perform multiplication: 5 * 3 = ".$multiplication ."<br />"; 10.echo "Perform division: 15 / 3 = ".$division."<br />"; 11.echo "Perform modulus: 5 % 2 = " . $modulus ?>
�� ��� ��� ���� &�� :����-
j9�4��9� ������� j9�4��9� ������� j9�4��9� ������� j9�4��9� ������� ( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR( COMPARI SON OPERATOR)))) &� Operator ����� �� ������$�� &� ��@� relationship '� ���।&� Operator ������� statement &� ��6� ���%� ��� $ ��� statement true ���� false.
&���� �,�� ����^6 ��2� Comparison Operator :$� ,�-
$x=4 # $y=5 @��
Operator English Example Result
== Equal to $x=$y False
!= Not equal to $x!=$y True
< Less than $x<$y True
> Greater than $x>$y False
<= Less than equal to $x<=$y True
>= Greater than equal to $x>=$y False
�d2 ������� �d2 ������� �d2 ������� �d2 ������� ( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR)( STRI NG OPERATOR) &���6� %�(� %��� :���2 %� ����,��# ����2-“”, ‘’
ARI THMETI CARI THMETI CARI THMETI CARI THMETI C �2�2�2�2 ASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATORASSI GNMENT OPERATOR �� COMBI NATI ON�� COMBI NATI ON�� COMBI NATI ON�� COMBI NATI ON Programming & &��� ����'6 ��" ,�- &��� ������$���� ���: c ,��� ��N����,3�� (���� Q�`।%�� 3�: F ��� ��N��6 '��6�,��
$counter=$counter+1; 3��,�� ���Q�� &���� ���
$counter+=1;
Pre/Post-Increment &��&��&��&�� Pre/Post-Decrement:
8������ &��� �m�6 ��� ,�6 ����,&��� %����� �� ��� � ! %�2 ��� �����$�� �� F ��� ��N���� �� �������
$x++ 3�� $x += 1; � �� $x = $x + 1 &� ����।
%� ������� Q�` ��@� “-” ��������� ����^6 ,��।
8.
������� �K�34�� 0b���K� ������� �K�34�� 0b���K� ������� �K�34�� 0b���K� ������� �K�34�� 0b���K� ( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )( PHP Condi t i onal St at ement )������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
����� ��6 � 8�� ����� action �$�� "�� ������� ����� ����^6 ,$।@��� %�� %��� #�$������ &�� &��� feature 3�(���6 '�� 3��6 3�: �8 %��� ����� :���� FG ��� %�( i� �� 6�,�� :���� “Good Morning” %� 3�: �8 ����� n ��� ��i� �� 6�,�� :���� “Good evening” &� @���� ��� &� '�$# �"�:�� # ���!��S! ��"(���� ���6 Conditional
statement &� :����,condition &� 8�� ���o ��� ��&�'�� 4$��5$���� ��"(���� ���6� ���। ��&�'�� 6 ��$� @���� Conditional statement %�2-
*if statement
*if…else statement
*if…elseif…else statement
*Switch statement
* I F STATEMENT* I F STATEMENT* I F STATEMENT* I F STATEMENT
if statement A �:�$ ��2� ��! execute ��� ,$ 3�� %���:� :$� condition A true ,$।���' 8:�,���� %8���� ,��
Have a nice day 3�: p �:� Saturday ,$ 3�:� ��!�� ���� ��� ������। 1.<?php 2.$d=date("D"); 3.if ($d=="Sat") 4.echo "Have a nice Day"; 5.?>
* I F* I F* I F* I F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT %-� ���# 6� &� � �����2� 3�: ���k� �� 6�,�� ��� �� ����,�� ,�� 3�: ���k� �� ����,���।&��� if…else statement
&� 8:�,��।&(�����6� ���� ��$ %��� ��I��� ����,�� ��� ��� &�� ��@� &���� ��&�'�� ��! �:�$ ����। 1.<?php 2.$d=date("D"); 3.if ($d=="Sat") echo "Have a nice Day"; 4.else 5.echo “Today is not saturday”; 6.?>
:��� condition 3�� �:�$�2 3�: ��� true ,$ � ��n ��!�� 3�:� ��� ������ ��:� 3�: Saturday ,$ 6�,�� %8���� ,��Have a nice day %� 6� ��,�� Today is not Saturday.
* I F* I F* I F* I F…ELSEI FELSEI FELSEI FELSEI F…ELSE STATEMENTELSE STATEMENTELSE STATEMENTELSE STATEMENT
&� statement ]��� &� �� &���@� ���!� \� execute ��� 3�$। view source print? 01.<html> 02.<body> 03.<?php 04.if ($number>=60) 05.echo "First Division"; 06.elseif ($number>=45 and $number<60) 07.echo “Second Division”; 08.elseif($number>=33 and $number<45) 09.echo "Third Division"; 10.else 11.echo “Failed”; 12.?> 13.</body> 14.</html>
9.
������� �9� ����������� ������� �9� ����������� ������� �9� ����������� ������� �9� ����������� ( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)( PHP Loop Tut or i al i n Bangl a)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%�� %��� &���" ������ ���6 %���:� ������ ����� ���( 3�� &�� ��� nq�� ������ &� ��@� ���� �� @��� &�� � � Fqq����"� ��@� ��� �6���:।�.�/���� & �"�� �������� ,�- &��� �'<� ����� &��� �g����b�o� ��" ��$� ���� ����� ��� 3�$।��� �:�$
&(���� ��� 3�$। ��� ,�- &�� &��� statement 3�� �:�$ &��� ���!� \� � ���: c ��$���� execute ��� 3�$ 36Q� �� %���:� ��"�� �;
,$। l @���� ��� %�2-
While Loop
Do…while Loop
For Loop
Foreach Loop
10.
������� ������� ������� ������� While While While While �9��9��9��9� ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
3�� &��� condition true ,$ 6�� while ��� A &��� ��! \� � execute ���।
�2� j�2� j�2� j�2� j
1.while (condition) 2.{ 3.code to be executed; 4.}
3�: condition false ,$ 6�� =������ ��6� ��!A &�N�$ 3�$।3�� ��;� =����A %��� 6�� condition %��� '�����,true ,�� ��! %��� execute ����।condition & 36��� :$� %�2 66��� &���� '����।�3��: 01.<html> 02.<body> 03.<?php 04.$i=1; 05.while($i<=5) 06.{ 07.echo "The number is " . $i . "<br />"; 08.$i++; 09.} 10.?> 11.</body> 12.</html>
. �� i=1. &��� while($i<=5) � ��n ���A 66Q� '��� 36Q� I &� ��� n �� 2�� �� ���� ,��।%� ���A .�6��� F
��� ��N��।���!A ��� ���� %8���� %��� &��-
The number is 1The number is 2The number is 3The number is 4The number is 5
&��� I &� ��� r �:�� �� %8���� %���?��2�� %����� ���� 6�� &A while loop &� ��� ������� 6�� ��! execute
,����।
DODODODO…WHI LE LOOPWHI LE LOOPWHI LE LOOPWHI LE LOOP &�� while loop &� �6� ��@� �� �� &�� W 3 condition A ��; test ��� ,$,�����6 ���� �����6 ,3�� ,$ while ���
&।� �n ����Q &���� ��� A execute ,���।
�2� j�2� j�2� j�2� j
1.Do 2.{ 3.Code to be executed 4.} 5.While(condition);
3�� ���'� 8:�,��A� ��!A# 8���� �6 &�� %8���� :�� ��@� ��" ���� ��V����। 01.<?php 02.$i=1; 03.do 04.{ 05.$i++; 06.echo "The number is " . $i . "<br />"; 07.} 08.while ($i<=5); 09.?>
��j &���� 3�: i=6 :� 6�,�� �� ,��?���'� �6
This is line 6
This line is outside while loop.so it will not repeat.
:��� ��� A . ���� '��� 2�N�� &���� ��! execute ,�$�2।. ���� execution &� �� '� ����2 3 ���A repeat ,��
����?��j while loop & . ����� &� '� ,$।
11.
������� 1� �9� ������������������ 1� �9� ������������������ 1� �9� ������������������ 1� �9� �����������( PHP For Loop)( PHP For Loop)( PHP For Loop)( PHP For Loop) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
&� ��� A &��� "A�।�� ��� &� ��" while ��� �:�$# ,$,6�� ��2� ����@�� ����� &A ���^6 ,$।
�2� j�2� j�2� j�2� j
1.for (init; condition; increment) 2.{ 3.code to be executed; 4.}
for loop statement =������ ��6� HA expression �$ 3(���� ����L�� ]��� ���K ,$।F� A assignment statement(loop control variable),. ���� ���A �g����b�o� %�(� &�� &���� execution ,$।G$ A Boolean expression 3�� .�6��� �g����b�o� %�(� &���� &� ��� ���s6(evaluate),$,&� ��� true ,�� �g����b�o '��� %� false return ��� 6�,�� �g����b�o �t ,�$ 3���।H$ A �:�$ loop control variable &� ��� ��N��6 �� ����6 ����^6 ,$।���'�
8:�,��A :��� ���A ���� ,�$�2 i=1 �:�$ &�� &A '��� 36Q� I &� ��� n &� '�$ 2�� �� ���� ,$।%� I &� ��� F ��� ��N��। 1.<?php 2.for ($i=1; $i<=5; $i++) 3.{ 4.echo "The number is " . $i . "<br />"; 5.} 6.?>
Output
The number is 1The number is 2The number is 3The number is 4The number is 5
3���� expression ���� �� &�A�6 &���@� expression ���6 ����,3(���� ��� ]��� ���K ,��।3�: Boolean
expression ���� ��� 6�,�� &� default ��� true ,$।&� 8:�,��� ��(���� %8���� F-Fq ,��। %����� ��� %�2 ��� foreach loop &A array &� ��� ����^6 ,$ 6�� ��� %��2
12.
������� ���� ����������� ������� ���� ����������� ������� ���� ����������� ������� ���� ����������� ( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)( PHP Ar r ay Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
&��� ������� &��� single value &� ��`(container).��j ����� &���@� value’� container �� ��`।&��� ����� ,�
��2� 8��:�� ���� (R6 3���� .�6��A 8��:���� ���: c value %�2-key �� index ��� 3�� �:�� 8��:��A�� ���� ��� ,�। @��� %���� ���2 ��2� �,��� ����� ��� %�2 &�� 3�: &(������ ����� single variable & store ��� ����6 '�� 6�,�� &��,��-
$city1= “Dhaka”
$city2= “Chittagong”
$city3= “Rajshahi”
$city4= “Sylet”
$city5= “Khulna”
$city6= “Barishal”
��j &��� ����� &��(������ &��� ��������� & @�� ����6 ����।����� ��@��� (>� �e�6 ,�- ��2� 8��:���� 5�(series of element) 3�� 8��:��(���� index q �� ���� ,�� 5�������� ��u�6 ����।��� �������� ����� ��� 3�� ���'�� �,"A ,�-- 1.<?php 2.$city=array(“Dhaka”, “Chittagong”, “Rajshahi”, Sy let”, “Khulna”, “Barishal”, “Barishal”); 3.?>
���� &��� variable & �� �,��� ��� store ,�� (�2,.�6A �,��� ��� &� &�A 8��:�� &�� .�6A 8��:��� &�A index ���: c ,�� �(���2।array’� F� 8��:�� &� index/key ,�- q 6�,�� &���� Dhaka[0],Chittagong[1]… &��������(����।&�� %��� 3���� 8��:�� &� index number 8�d� ��� � 8��:��A ��6 �����।�3�� 1.<?php 2.Print “$city[3]”; 3.?>
6�� 3�: %��� '�� 6�,�� ������ &� �!�v ����� ����6 � ��� �:�6 ����,=> &� �������A �:��।@�� %�� '��- &� 8����
�����A� starting index 2 �:�� ���� ,�� 6�,�� &���� ����6 ,��। 1.<?php 2.$city=array(2=>“Dhaka”, “Chittagong”, “Rajshahi”, “Sylet”, “Khulna”, “Barishal”, “Barishal”); 3.?>
&� ������� 3���� 8��:���� �g�� ����^6 ,�6 ���� 6�� index ���: c ���� "��।
������������ ���������������� ���������������� ���������������� ���� ( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY)( ASSOCI ATI VE ARRAY) &6Q��6� �g� ������ index/key :���� %��� '���� string # ����,�� ���6 �����।&����� associative array ���।�3��: 1.<?php 2.$ages = array("adnan"=>32, "rezwan"=>30,"refat"=>34); 3.?>
���O�����434�����O�����434�����O�����434�����O�����434�� ���� ���� ���� ���� ( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL AR( MULTI DI MENSI ONAL ARRAY)RAY)RAY)RAY) &���� &��� ������ ��6� .�6A 8��:�� &�A ����� ,�6 ���� %��� &� ��� ������ .�6A 8��:��# &�A ����� ,�6 ���� &��
&���� %�#। 1.<?php 2. 3.$continents=array("Asia"=>array("Bangladesh","Ind ia","Pakistan"), 4."Europe"=>array("England","France")"Africa"=>arra y("Kenya", 5."Libya","Somalia")); 6. 7.?>
���������������� �r�� �9��2�r�� �9��2�r�� �9��2�r�� �9��2
FOREACH LOOPFOREACH LOOPFOREACH LOOPFOREACH LOOP @��� &�A associative array %�2 &���� %��� �g����b�o ���6 '�� foreach statement �:�� &�� ���6 �����।�3��: 1.<?php 2.$city=array(“Dhaka”, “Chittagong”, “Rajshahi”, “S ylet”, “Khulna”, “Barishal”, “Barishal”); 3.foreach ($city as $value) 4.{ 5.echo “$value.<br>”; 6.} 7.?>
Output
Dhaka
Chittagong
Rajshahi
Sylet
Khulna
Barishal
Barishal
13.
������� 1�234 ����������� ������� 1�234 ����������� ������� 1�234 ����������� ������� 1�234 ����������� ( PHP Funct i on)( PHP Funct i on)( PHP Funct i on)( PHP Funct i on) ������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
&�� ,�- &��� ��� 3�� %�� ����� ��!\��� �:�6 ���� &�� ��� �� ��� @�� !�� p ��!\��� ��-�6 execution ����6
����।&�� ��&�'�� &� �g� ��K ���6 �����।.�� wqq &�# ��� ��v �� ����� %�2 ��&�'�� 6।
&��� ������� 3�� �� ��� ,� 6��� &�� execute ,� %� ��"� 3������ "��(� �� &��� ������� �� ��� 3��।
�2� j�2� j�2� j�2� j
1.function functionName() 2.{ 3.code to be executed; 4.}
A��:������� ��� :��� ��� &�� ��� �:� 3�� :��� 3� ��7� 3�� �����A �� ����।
������� ��� �Q� �� _ �:�� ���� ,�6 ����,��_�� �:�� ���� ,����। &��� simple ����� 3�� �:�� %��� ��� ���� 01.<?php
02.function writeName() 03.{ 04.echo "Md.Rejoanul Alam"; 05.} 06. 07.echo "My name is "; 08.writeName(); 09.?>
Output
My name is Md.Rejoanul Alam
1�23�4 ��������� 0q�1�23�4 ��������� 0q�1�23�4 ��������� 0q�1�23�4 ��������� 0q�a ��a ��a ��a �� ������ ���������� 3�( ��� %�# ��������A ��u���� 3��,&�� &�:� PHP variable &� �6�।������� ��� ���� �� &��=������ ��6� ��� ,�।�3�� 01.<?php 02.function writeName($fname) 03.{ 04.echo $fname . " Alam.<br />"; 05.} 06. 07.echo "My name is "; 08.writeName("Rejoanul "); 09.echo "My Father's name is "; 10.writeName("Samad"); 11.echo "My brother's name is "; 12.writeName("Anjirul"); 13.?>
Output My name is Rejoanul Alam.My Father's name is Samad Alam.My brother's name is Anjirul Alam. %����� 8:�,�� 01.<?php 02.function myGreeting($firstName, $lastName){ 03.echo "Hello there ". $firstName ." ". $lastName."!<br />"; 04.} 05.myGreeting("Jack", "Black"); 06.myGreeting("Ahmed", "Zewail"); 07.myGreeting("Julie", "Roberts"); 08.myGreeting("Charles", "Schwab"); 09.?>
output
Hello there Jack Black!Hello there Ahmed Zewail!Hello there Julie Roberts!Hello there Charles Schwab!
&��� ������� ����� return ���6 return statement ����,�� ���6 ,�।�3��
view source print? 01.<?php 02.function add($x,$y) 03.{ 04.$total=$x+$y; 05.return $total; 06.} 07. 08.echo "1 + 16 = " . add(1,16); 09.?>
14.
������� 1�R ����������� ������� 1�R ����������� ������� 1�R ����������� ������� 1�R ����������� ( PHP For m)( PHP For m)( PHP For m)( PHP For m)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
&6Q� ��&�'��’� 36 ��2� ��� ,� &��� 6� .�$��(� ��$ &���2।�� �8"�� �� 6 � ���6 ����^6 ,$।&� 6 � ��&�'�� �" �:�$3�$ &�� ��&�'�� �:�$� &�� ��� ,$।��&�'�� 6 :�A ����$�� %�2 3� �� ,�6 !��(�8"�� �����) 6� �� %��6 ����^6 ,$-
$_GET &�� $_POST.&��� &�'A&�&� �� :����� ,� 3�� :�A ����� ��x %� &�A ������ ���� %�2। 1.<form action="welcome.php" method="post"> 2.Name: <input name="fname" /> 3.Age: <input name="age" /> 4.<input type="submit" /> 5.</form>
�8"�� 3�� �� A �g�� ��� ������ ����� �L� ���� 6�� !�� ��&�'�� ����� '�� 3��� 3�� ��� “welcome.php” &����%����� �"��� ��P$ �Q� ����2� 3 ��!A�6 method=POST :$� %�2,Form &� !�� ��&�'�� 6 ���6 :�A �e�6
����,�� ,$ POST &�� GET.
welcome.php ����A ,�� &��
1.Welcome <?php echo $_POST["fname"]; ?>!<br /> 2.You are <?php echo $_POST["age"]; ?> years old.
&�� @��� %��� �� A�6 ����� "�$(�$ �:��� rezwan &�� age �:��� 24,&��� ������ ����� �L� ���� %8���� ����� &��
Welcome rezwan!You are 24 years old.
15.
������� ������� ������� ������� $_$_$_$_GET GET GET GET 0�g� 0�g� 0�g� 0�g� ( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod)( PHP $_GET Met hod)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
��� � 6 � GET � ! & ��>��� ��� 6 � =�8"�� &�U����� .:�� 6 ,$ &�� ���� :��6 ��$।6�2�N� �6�� W 6 � ��>���� 3���6�� &�A �E�� %�2 ��@���6 ��� �y Gnq A character (&�� %��� ��� �� &�� =�8"���� 8�� ��� � ��� 3 6��:� URL &�D:a � �6:�� ,��।)3�� 1.<form action="welcome.php"method="get"> 2.Name: <input name="fname" /> 3.Age: <input name="age" /> 4.<input /> 5.</form> 3�� �8"�� ������ ����� �L� ���� 6�� =�8"�� &�U����� ���'� �6 :����
http://www.w3schools.com/welcome.php?fname=Peter&age=37
welcome.php ����A &�� $_GET Method ����� ����,�� ��� ��� � !�� ��/, ����। 1.Welcome <?php echo $_GET["fname"]; ?>.<br /> 2.You are <?php echo $_GET["age"]; ?> years old!
16.
������� 0��b 0�g� ����������� ������� 0��b 0�g� ����������� ������� 0��b 0�g� ����������� ������� 0��b 0�g� ����������� ( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod)( PHP $_POST Met hod)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
&� �e�6�6 3 6 �� ��>���� ,�� 6� �8 :��6 ������ =�8"���� &�U�����# .:�� 6 ,$��। &���� ����@� ,� 36 �-� 6 � ��>��6 �����(%��� ��� �y zMb �3 < ��>���� 3�$।) <form action="welcome.php" method="post"> Name: <input name="fname" /> Age: <input name="age" /> <input />
</form>
&��� 3�� �8"�� ������ ����� �L� ���� 6�� =�8"�� &�U����� ���'� �6 :����
http://www.w3schools.com/welcome.php
%� &��� ��� � !�� $_POST Method �e�6�6 (b,E6 ,��। Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old.
o4 0 �4�� �t�� ��4 o4 0 �4�� �t�� ��4 o4 0 �4�� �t�� ��4 o4 0 �4�� �t�� ��4
�{ 6 � ,�� GET Method %� ��� 6 � &�� �8"�� �� password �6���: Q�` POST Method ����,�� ��� ���।
BBBB....������� �������������� �������������� �������������� ������� 1.1.1.1. ������� ������� ����������� ������� ������� ����������� ������� ������� ����������� ������� ������� ����������� | | | | ���� � ���� � ���� � ���� � ( Advanced PHP ( Advanced PHP ( Advanced PHP ( Advanced PHP Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
webcoachbd.com &� &� ����� ������ ��&�'��� ���!��S! A8�������� ���� 3��-��&�'�� ���,W��,����,!�,&��
,����� �6���:।
2.
������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ������� 0�� 1�234 ����������� ( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)( PHP Dat e Funct i on Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
������� 0�� 1�234 ������� 0�� 1�234 ������� 0�� 1�234 ������� 0�� 1�234 ( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON)( PHP DATE FUNCTI ON) %��� %���� #������"� ��� ���| �6 ��� 6����/��� :���6 '���6 ����� 6�� ��&�'�� &� date() ����� ]��� &A ���6�����।�3��
view source print? 1.<?php 2.echo date("Y/m/d") . "<br />"; 3.echo date("Y.m.d") . "<br />"; 4.echo date("Y-m-d") 5.?>
Output
2009/05/11
2009.05.11
2009-05-11
&���� %��� 3 ������A �2Z ���� �A �:�� �:���।
3.
������� ������� ������� ������� �489� 1�234 ����������� �489� 1�234 ����������� �489� 1�234 ����������� �489� 1�234 ����������� ( PHP I ncl ude Funct i on Tut or i al i n ( PHP I ncl ude Funct i on Tut or i al i n ( PHP I ncl ude Funct i on Tut or i al i n ( PHP I ncl ude Funct i on Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
%��� ��- ����� ��� �� &�M��8� ���� %�(� ��&�'�� &� &��� ������ ��� ��� %����� ��&�'�� ����� i� ���$ �:�6 �����
include() ����� �:�$।
Require()-�� � ,�� fatal error((��6� �� �):���� &�� �)*A &�M��8� ��� �t ��� �:��। Include()-�� � ,�� �6� ��� �:�� &�� �)*A &�M��8� ����
& ����� :�A �:�$ ���� ��" ��' 3�$ 3�� %��� 3�: &��� ���,,!��,�� ��� �� 3���� ��� 3�� %��� '�� 3 %��� #�$� ��������� ��"� &�� :���� 6�,�� &��� ��&�'�� ����� ���(���,,!��,�� ��� �6���:) D6�E ��� ��� �� ��" & ����� :�A �:�$ 3�( ����:�6 �����।��� %��:� %��:� ���� .�6A ��" %� &(���� 3�( ���6 ,���।%��� 3�: &� include ����� ��� ��2� %��!����� ��� �� &��� ��� �6� � �"��� 3�( ���� 6�,�� ��� �� ��" �(�$� 3�K ,��।�b ����� �� ��" �(�$ %� 3�( ���6,����।8:�,��,@��� “menu.php”���� &��� ���� ���2 ���'� �6
1.<a href="/default.php">Home</a> 2.<a href="/tutorials.php">Tutorials</a> 3.<a href="/references.php">References</a> 4.<a href="/examples.php">Examples</a> 5.<a href="/about.php">About Us</a> 6.<a href="/contact.php">Contact Us</a> &���� 3�( ���6 ,�� &����
view source print? 01.<html> 02.<body> 03.<div> 04.<?php include("menu.php"); ?> 05.</div> 06.<h1>Welcome to my home page.</h1> 07.<p>Some text.</p> 08.</body> 09.</html>
4.
������� ��� ���� 1�234 ������� ��� ���� 1�234 ������� ��� ���� 1�234 ������� ��� ���� 1�234 ( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)( PHP r equi r e Funct i on Tut or i al i n Bangl a)������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
require() ����� include() &� �6� ��@� ��` �� � ,�� ����� %'�� ���� &� 8�� ���o ��� &��� ��V6� %�2।
Include() & �� � ���� &��� ���" �:��। 01.<html> 02.<body> 03. 04.<?php 05.include("wrongFile.php"); 06.echo "Hello World!"; 07.?> 08.</body> 09.</html>
Error message:
Warning: include(wrongFile.php) [function.include]:failed to open stream:No such file or directory in C:\home\website\test.php on line 5 Warning: include() [function.include]:Failed opening 'wrongFile.php' for inclusion(include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5 Hello World!
Notice that the echo statement is executed! This is because a Warning does not stop the script execution.
require() Function &&&& �� ��� ��� ��� � �������������������� &���&���&���&��� ���"���"���"���" �:���:���:���:��
Now, let's run the same example with the require() function. 1.<html> 2.<body> 3.<?php 4.require("wrongFile.php"); 5.echo "Hello World!"; 6.?> 7.</body> 8.</html>
Error message:
Warning: require(wrongFile.php) [function.require]:failed to open stream:No such file or directory in C:\home\website\test.php on line 5 Fatal error: require() [function.require]:Failed opening required 'wrongFile.php'(include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5
echo statement &���� &�M��8� ,$���
5.
������� 1��� 1�234 ������� 1��� 1�234 ������� 1��� 1�234 ������� 1��� 1�234 ����������� ����������� ����������� ����������� ( PHP Fi l e Funct i on Tut or i al i n ( PHP Fi l e Funct i on Tut or i al i n ( PHP Fi l e Funct i on Tut or i al i n ( PHP Fi l e Funct i on Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
fopen &�� �:�� ��&�'�� 6 ���� ���� 3��।�3�� 1.<html> 2.<body> 3.<?php 4.$file=fopen("welcome.txt","r"); 5.?> 6.</body> 7.</html>
fopen &��� =����� :�A �"��� %�2 &�A “welcome.txt”� ��n &� ����� ����A ����� &�� �]6E�A “r” &�� &���
���������� 3�� �:�� R� ��� :�� 3�� ����A ��� ��}��(���!)�g���।&���� “r” :�� %�2 6�� &A read only ���! �����। &��� %��� ��2� ����������
Modes Description
r Read only. Starts at the beginning of the file
r+ Read/Write. Starts at the beginning of the file
w Write only. Opens and clears the contents of file; or creates a new file if it doesn't exist
w+ Read/Write. Opens and clears the contents of file; or creates a new file ifexist
a Append. Opens and writes to the end of the file or creates a new file if it doesn't exist
a+ Read/Append. Preserves file content by writing to the end of the file
x Write only. Creates a new file. Returns FALSE and an error if file already exists
x+ Read/Write. Creates a new file. Returns FALSE and an error if file already exists
3�: ���: c ����A fopen() function A ����6 ��� ,� 6�,�� ���'� �6 ��!A ���� &��� ���" :����� ,� 1.<html> 2.<body> 3.<?php 4.$file=fopen("welcome.txt","r") or exit("Unable to open file!"); 5.?> 6.</body> 7.</html>
� �� 1��� 08�U ��� �� 1��� 08�U ��� �� 1��� 08�U ��� �� 1��� 08�U ��
fclose() function �:�� ���� ��� ���� �t ��� 3��। 1.<?php 2.$file = fopen("test.txt","r"); 3. 4.//some code to be executed 5. 6.fclose($file); 7.?>
ENDENDENDEND---- OFOFOFOF---- FILE FILE FILE FILE 0� ��0� ��0� ��0� ��
&�� �:�� ������ ��; �~2���� ���� 6� '� ��� ,�। if (feof($file)) echo "End of file";
&�� ����� &� ��� ���" ���(।
� �� 1��� � �� 1��� � �� 1��� � �� 1��� LINE BY LINE LINE BY LINE LINE BY LINE LINE BY LINE ������������ fgets() function A �:�� ��&�'�� 6 &�A &�A ��� ���� �u� 3��।&� �����A �� ���� ��� ��� ���� ���: ��A ����
����� '�� 3��।���'� 8:�,��� :��� &A &�A &�A ��� ���� �u�� �; �� �~2� �3 <। 01.<?php 02.$file = fopen("welcome.txt", "r") or exit("Unable to open file!"); 03.//Output a line of the file until the end is rea ched 04.while(!feof($file)) 05.{ 06.echo fgets($file). "<br />"; 07.} 08.fclose($file); 09.?>
CHARACTER BY CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTCHARACTER BY CHARACTER ER ER ER � �� 1��� ���� �� 1��� ���� �� 1��� ���� �� 1��� ���
fgetc() function A &��� ���� �� &��� &��� ��� �Q� �u��।
���'� 8:�,��A ���� �� &�A &�A ��� �Q� �u��। view source print? 1.<?php 2.$file=fopen("welcome.txt","r") or exit("Unable to open file!"); 3.while (!feof($file)) 4.{ 5.echo fgetc($file); 6.} 7.fclose($file); 8.?>
6.
������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ������� 1��� ?����� ����������� ( PHP Fi l e Upl oad Tut or i al i n ( PHP Fi l e Upl oad Tut or i al i n ( PHP Fi l e Upl oad Tut or i al i n ( PHP Fi l e Upl oad Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#������"#������"#������"#����� %��%��%��%�� &� ������� ��@��� �8"�� %���� ��� ��� ���� %����! ���6 �����।�3�� 01.<html> 02.<body> 03. 04.<form action="upload_file.php" method="post" 05.enctype="multipart/form-data"> 06.<label for="file">Filename:</label> 07.<input /> 08.<br /> 09.<input type="submit" name="Submit"value="Submit" /> 10.</form> 11.</body> 12.</html>
&���� action="upload_file.php" &�� method="post" :�� ,���2 � ��n ������ ����� �L� ���� ��� � !�� (����
��� � ! &� ��@��� upload_file.php ����� ����� 3���।&��� :�� upload_file.php 6 !�� (���� ���� &�� �� ���। Upload_file.php �)*A ,�� &��� 01.<?php 02.if ($_FILES["file"]["error"] > 0) 03.{ 04.echo "Error: " . $_FILES["file"]["error"] . "<br />"; 05.} 06.else 07.{ 08.echo "Upload: " . $_FILES["file"]["name"] . "<br />"; 09.echo "Type: " . $_FILES["file"]["type"] . "<br />"; 10.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; 11.echo "Stored in: " . $_FILES["file"]["tmp_name"]; 12.} 13.?>
global PHP $_FILES ����� ����,�� ��� %��� L��� ��+8��� �� ������ ��� ��� ���� %����! ���6 ������।
• $_FILES["file"]["name"] – %����!�b 6 ������ ���
• $_FILES["file"]["type"] - %����!�b 6 ������ type
• $_FILES["file"]["size"] - %����!�b 6 ������ size
• $_FILES["file"]["tmp_name"] %����!�b 6 ������ temporary copy 3�� ��� ��� ����Q6 ���। %��� ��- ���� ���� � &�� �� %����! ���6 ����� 6� R� ��� �:�6 ����� �����o�� "�� 3��6 3���� �8 3���� ����%����! ���6 �� ����।�3�� Gq ����������� ��@� ������ ���� %����! ���6 ������� �� ��@� .jpeg,.jpg,.gif ��������
���� %����! ���6 ����� �6���: R� ��� �:�6 �����।
01.<?php 02.if ((($_FILES["file"]["type"] == "image/gif") 03.|| ($_FILES["file"]["type"] == "image/jpeg") 04.|| ($_FILES["file"]["type"] == "image/pjpeg")) 05.&& ($_FILES["file"]["size"] < 20000)) 06.{ 07.if ($_FILES["file"]["error"] > 0) 08.{ 09.echo "Error: " . $_FILES["file"]["error"] . "<br />"; 10.} 11.else 12.{ 13.echo "Upload: " . $_FILES["file"]["name"] . "<br />"; 14.echo "Type: " . $_FILES["file"]["type"] . "<br />"; 15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; 16.echo "Stored in: " . $_FILES["file"]["tmp_name"]; 17.} 18.} 19.else 20.{ 21.echo "Invalid file"; 22.} 23.?>
?����� �j 1��� 0�� ��?����� �j 1��� 0�� ��?����� �j 1��� 0�� ��?����� �j 1��� 0�� �� ��o���o���o���o� %�(� ����2 8���� ��!(���� �:�� ��� ��� ���� �}��E(temporary copy) ���� �� ,�,}��E ��� ����� "�� &���� ��!A����� 01.<?php 02.if ((($_FILES["file"]["type"] == "image/gif") 03.|| ($_FILES["file"]["type"] == "image/jpeg") 04.|| ($_FILES["file"]["type"] == "image/pjpeg")) 05.&& ($_FILES["file"]["size"] < 20000)) 06.{ 07.if ($_FILES["file"]["error"] > 0) 08.{ 09.echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; 10.} 11.else 12.{ 13.echo "Upload: " . $_FILES["file"]["name"] . "<br />"; 14.echo "Type: " . $_FILES["file"]["type"] . "<br />"; 15.echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; 16.echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; 17. 18.if (file_exists("upload/" . $_FILES["file"]["name"])) 19.{ 20.echo $_FILES["file"]["name"] . " already exists. "; 21.} 22.else 23.{
24.move_uploaded_file($_FILES["file"]["tmp_name"], 25."upload/" . $_FILES["file"]["name"]); 26.echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; 27.} 28.} 29.} 30.else 31.{ 32.echo "Invalid file"; 33.} 34.?>
�)*A :��� %�( ��� &� ����� ��� ���� ��� ��� %�2 ���� ,�� ���� move_uploaded_file �����A� ��,��3� ���: c�b 6
��x��� �(�� ����A �� ,��।
8���� 8:�,��� “upload” ����� &��� ��x��� �(�� ����A �� ,��।
7.
������� C� ����������� ������� C� ����������� ������� C� ����������� ������� C� ����������� ( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)( PHP Cooki e Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
&�"� �8"�� � ���K ���6 &�� ���^6 ,�।&�� ,�- &��� 2�� ���� 3�� ��� �� �8"���� �����6 ���(�� :�(&�� :�/"�� ���
����)।ধরুন %��� %���� ���,� ��� '� ����2� &�� ���Q� �� %��� ��� '� ���� "�� ���� �� ���6 '����� 6��
:���� 3 %� %����� �8"�� �� ���� ���6 ,�-��,���,� ���" ��� %���� ��� �8"�� �� &� "��(�� :���-,&��� �� W��
���� 3���� %���� &� 6 �(�8"�� �� ���#��! �6���:)����Q6 �2�।
C� � ��� ij�k ��jC� � ��� ij�k ��jC� � ��� ij�k ��jC� � ��� ij�k ��j t�t�t�t�
setcookie() function &�� ����^6 ,� W�� D6�E ���6।
setcookie() function A ����� <html> ���( &� %�( ���6 ,��। setcookie(name, value, expiration);
namename:&�� W��� ���,��� &� ���A ����,�� ���6 ,�� W��A ��n ��6 । value:&�� W���6 ��� ���Q� ��� ����,�,�� ����^6 W�� ,�- username(string)&�� last visit(date)
expiration:&�� #� ��� 3�� W��A� ���: �; ,��।3�: %��� &� ����:� 6����A(W��A �6Q� ����)R� �� ��� :�
6�,�� =�8"�� ��� �� ���� ��� ��� � W��A ���2 3���। ���'� 8:�,��� %�� &�A W�� D6�E ��� 3�� �8"�� �� ��; ��� #������A visit ����2� �� 6 � ���Q� ��� ����� 3��6���� ��� &�� �:�� �� ����6 ���� &�"� �8"�� �6 a�a� %��� ����� %���।%��� '���� W��� ���:��� R� ��� �:�6 �����3�� %�� &���� ���:��� Hq �:� ��� �:���2।� ��n &���� #� ��I �8"���� ignore ��� ,���2 3��� Hq �:��� ��6�� &����
����� i�����। 1.<?php 2.$expire=time()+60*60*24*30;
3.setcookie("user", "rezwan",$expire); 4.?> 5.<html> 6......
C� ���� C� ���� C� ���� C� ���� ((((RETRIEVERETRIEVERETRIEVERETRIEVE) ) ) ) �� �� �� ��
3�: W��� ���: �; �� ,�� ��� 6�,�� ��&�'��� $_COOKIE variable �:�� W�� retrieve ��� 3��। 1.<?php 2.if(isset($_COOKIE['lastVisit'])) 3.$visit = $_COOKIE['lastVisit']; 4.else 5.echo "You've got some stale cookies!"; 6. 7.echo "Your last visit was - ". $visit; 8.?>
&� ���! isset ����� ����,�� ��� ,���2 &�� ���P6 ���6 3 "lastVisit" W�� &��# �8"���� �����6 %�2 ����,3�: ���
6�,�� �8"�� �� ��; ��� visit ����2� 6� :�� 3���।
C� �9�v 01��C� �9�v 01��C� �9�v 01��C� �9�v 01��
W�� ��2�� %�( &�� ���P6 ,�� ��� 3 W��� ���: �; ,���2 ����। view source print? 1.<?php 2.// set the expiration date to one hour ago 3.setcookie("user", "", time()-3600); 4.?>
8.
������� 0�34 ����������� ������� 0�34 ����������� ������� 0�34 ����������� ������� 0�34 ����������� ( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)( PHP Sessi on Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
3�� ��� &�?���� ���� ��" ����,�����,�t ���� �� ��� ����6 � ���� �� �t ���� &�� &��� ����� �6।��+8��� ���7%��� �।%��� ��� ��" ���� ����2�,��� �; ����2� &���� 6 � 6�� ���2 ���।��j �������� &��� ����� ,�-#��� ��� ����7�6 ������ %��� � %� &6Q� �� �����।��&�'�� ��� &� ������ ���@�� �:���2।��&�'�� ��� �8"���� 6 � ��� ������Q� ��� ���� ��� ����,���� "��।&� ��� 6 � �}��E &�� �8"�� ���� 6��( ���� ��� ��� 6� ���2 3��।3�: }��E���� ����6
'�� 6�,�� !������ �� ��� ����6 �����।��&�'�� ��� .�6A �8"���� "�� ���� ���'� unique id (UID) D6�E ���। ��&�'�� ���� �8"���� 6 � ���Q� ���� %�( ��� ���� ���6 ,��।��&�'�� ��� session_start() ����� �:�� ���� ���6 ,�
&�� <html> tag &� %�( ����6 ,�। 1.<?php session_start(); ?> 2. 3.<html> 4.<body>
5. 6.</body> 7.</html>
&����!A ��� ���� ��,��3� �8"���� ��� ��"��� ���� &�� &� ����� &��� %��! �:�� 6�� 6 � �� ��� ���� ����।
0�34 ������� �2��0�34 ������� �2��0�34 ������� �2��0�34 ������� �2��4 ��4 ��4 ��4 ��
��� 6 � ���Q� # 8e���� �R� 8��� ,� ��� ��������� $_SESSION ����,�� ���। 01.<?php 02.session_start(); 03.// store session data 04.$_SESSION['views']=1; 05.?> 06.<html> 07.<body> 08. 09.<?php 10.//retrieve session data 11.echo "Pageviews=".$_SESSION['views']; 12.?> 13. 14.</body> 15.</html> %8����
Pageviews=1
���'� 8:�,��A page view counter(page �6��� :�� ,���2 6� :��� "��) D6�E� "��।&A ���� "�� isset() �����A����,�� ��� ,�।&� �����A '� ��� :��� ‘views’ ��������� %�( ��� �� ��� %�2 ����।3�: ‘views’ variable ����� ��� 6�,�� %��� ����:� counter ��u��6 ����।%� 3�: �� ��� 6�,�� ‘views’variable D6�E ��� &�� &���� F ��
��� :�। 01.<?php 02.session_start(); 03. 04.if(isset($_SESSION['views'])) 05.$_SESSION['views']=$_SESSION['views']+1; 06.else 07.$_SESSION['views']=1; 08.echo "Views=". $_SESSION['views']; 09.?>
� �� 0�34 �2� �� � �� 0�34 �2� �� � �� 0�34 �2� �� � �� 0�34 �2� �� ( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI O( DESTROYI NG A SESSI ON)N)N)N) ��� !�� ���2 ���6 unset() or the session_destroy() function ����,�� ��� ,�।]
unset() function ���: c &��� ��� ��������� ���2 ���6 ����^6 ,�। 1.<?php 2.unset($_SESSION['views']); 3.?>
&��� ����� �+g� ���� ��� ���6 session_destroy() function ����^6 ,�। 1.<?php 2.session_destroy(); 3.?>
session_destroy() ����� reset ���� &�� &�6 ��� �� ��� ���� ����� �� 6 � ,������।
9.
������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ������� ��� J�K���� ����������� ( PHP Er r or Handl er Tut or i al i n ( PHP Er r or Handl er Tut or i al i n ( PHP Er r or Handl er Tut or i al i n ( PHP Er r or Handl er Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
3�� ��&�'�� �)* ������ �� ��� #��� &�?���� D6�E ����� 6�� error handling &�&�A (��f�g� �� ���� ���।3�: &��
(�� �) '��� ���! ��� a���6 ��� 6�,�� %���� .�/��A %� ��� ��� ,���� &�� �����o�"��6 7� �� ����। &� A8��������� &�� '��� &� ��2� .'��6 �e�6 ���� %���'�� ��� ,��।�3��
"die()" statements
Custom errors and error triggers
Error reporting
""""DIEDIEDIEDIE()" ()" ()" ()" 0b���K�0b���K�0b���K�0b���K� �t�� �� ��� �t�� �� ��� �t�� �� ��� �t�� �� ��� J�K�� ��J�K�� ��J�K�� ��J�K�� ��
&�� &��� 2�� ��! 3�� �MX ���� �����। 1.<?php 2.$file=fopen("welcome.txt","r"); 3.?>
3�: ����A� ��� ��I6� �� ��� 6�,�� =�8"��� ���'� �6 .:� � ����। Warning : fopen(welcome.txt) [function.fopen]: failed to open stream:No such file or directory in C:\webfolder\test.php on line 2 �8"���� 8���� �6 ���" �� ���K �:�� ���"� �6 ��@(�� ���" �:�6 �����।�3�� 01.<?php 02.if(!file_exists("welcome.txt")) 03.{ 04.die("File not found"); 05.} 06.else 07.{ 08.$file=fopen("welcome.txt","r"); 09.} 10.?>
&��� 3�: ����A �� ��� 6�,�� &� ���" :����। File not found
&� ��!A 8���� ���!� '�� &��� ��V।&�� &��� ��@��� �e�6 &�6 error ,�� �)* �t ,�� 3���।6�� & �e�6 ����,�� ���
���� ��� �R� ��।
�b� ��� J�K��� �b� ��� J�K��� �b� ��� J�K��� �b� ��� J�K���� ij�k ��� ij�k ��� ij�k ��� ij�k �� &���� %�� ��@��� &��� ��&�'�� ����� D6�E ��� 3�� &�� ,�� 3� call ��� 3��।&� ������ ����Q :�A(error level and
error message) &�� ��� �y ��'A (optionally: file, line-number, and the error context)���������� ����। error_function(error_level,error_message,error_file,error_line,error_context)
Parameter Description
error_level %����।�8"�� �b 6 �� ��� error report level �����: c ���।����� &���
value number ���6 ,��।���'� ����� ����� error report level :�� ,�।
error_message %����। �8"�� �b 6 �� ��� "�� error message ���: c ���।
error_file p�-�। p ����A� ��� 8�d� ��� 3���� �� � ,���2।
error_line p�-�। p ����A� ��� 8�d� ��� 3���� �� � ,���2।
error_context p�-�।&��� ����� 8�d�(Specifies an array) ��� 3���� �� ��������� &�� 6��:� ��� ���।
��� �������R2 �� ��4��� �������R2 �� ��4��� �������R2 �� ��4��� �������R2 �� ��4( VALUE)( VALUE)( VALUE)( VALUE)
Value Constant Description
2 E_WARNING run-time errors. �)�*� Execution �t ,���
8 E_NOTICE Run-time notices.
256 E_USER_ERROR �8"���b 6 ������ �� �।&�� E_ERROR &� �6 3�� .�/���� �� ��� :� PHP
function trigger_error() ����,�� ���। 512 E_USER_WARNING Runtime warnings generated by a call totrigger_error( )
1024 E_USER_NOTICE Runtime warnings generated by a call totrigger_error( )
4096 E_RECOVERABLE_ERROR Catchable fatal error.
8191 E_ALL �� errors &�� warnings, ��@� level E_STRICT 2�u�(E_STRICT PHP 6.0
&� E_ALL &� ��� ,��।)
��� � �� 1�234 ij�k��� � �� 1�234 ij�k��� � �� 1�234 ij�k��� � �� 1�234 ij�k � ��� J�K�� �� � ��� J�K�� �� � ��� J�K�� �� � ��� J�K�� �� U�U�U�U� 1.function customError($errno, $errstr) 2.{ 3.echo "<b>Error:</b> [$errno] $errstr<br />";
4.echo "Ending Script"; 5.die(); 6.}
&�� &��� ��@��� error handling �����।3�� &�� '��� 6�� &�� &��� error level &�� ���" ����।&� ���� &�� ���"
%8���� �,���� :���� �)* ���� ����।
��� J�K���� 0�� ��� J�K���� 0�� ��� J�K���� 0�� ��� J�K���� 0�� �������� ��&�'���6 �!�v �,���� &��� error handler ��v�� ���।%��� ��- ���� &� �����6 ���"� �6 error handler �:�6����� PHP 6।���'� 8:�,��� :�� ������ &� ���"� D6�E error handler ����,�� ���6 ,�
set_error_handler("customError");
3�,6� error handle ���� "�� %��� ���"� D6�E ����� ����,�� ���6 '��,6�� set_error_handler() &� &���
���������� :����,G� %����� ���������� 3�( ��� 3�6 ���� error level &� "��। &��� &��� 8:�,�� 01.<?php 02.//error handler function 03.function customError($errno, $errstr) 04.{ 05.echo "<b>Error:</b> [$errno] $errstr"; 06.} 07. 08.//set error handler 09.set_error_handler("customError"); 10. 11.//trigger error 12.echo($test); 13.?> 8���� ���!� %8���� ,�� &��
Error: [8] Undefined variable: test
0 �4 �9�� 0 �4 �9�� 0 �4 �9�� 0 �4 �9�� TRIGGER TRIGGER TRIGGER TRIGGER �� �� �� �� ��� �)* 3���� �8"�� !�� ����� ���6 ���� ����� trigger ��� 8����E 3�� �8"�� �� �/���@ �����
����।trigger_error() function �:�� &�� ��� ,�।&� 8:�,��� test ��������� 3�: F &� '�� �u ,� 6�� error ,��। 1.<?php 2.$test=2; 3.if ($test>1) 4.{ 5.trigger_error("Value must be 1 or below"); 6.} 7.?> %8����
Notice: Value must be 1 or belowin C:\webfolder\test.php on line 6
&��� error � �)�*� 3���� "��(�� trigger ��� 3�� &�� %����� ���������� 3�( ��� ���: c ��� �:�6 ����� 3 ��� error
level A trigger ��� ,���2। �������������������� error &�&�&�&� @��@��@��@��
• E_USER_ERROR
• E_USER_WARNING
• E_USER_NOTICE 8:�,��
3�: test ��������� &� ��� F &� '�� ��� ,� 6�,�� &���� E_USER_WARNING error A ,�� &�� &�� %��� ���"�
D6�E error handler A ����,�� ���। 01.<?php 02.//error handler function 03.function customError($errno, $errstr) 04.{ 05.echo "<b>Error:</b> [$errno] $errstr<br />"; 06.echo "Ending Script"; 07.die(); 08.} 09. 10.//set error handler 11.set_error_handler("customError",E_USER_WARNING); 12. 13.//trigger error 14.$test=2; 15.if ($test>1) 16.{ 17.trigger_error("Value must be 1 or below",E_USER_ WARNING); 18.} 19.?> %8����
Error: [512] Value must be 1 or belowEnding Script
��� ��a2��� ��a2��� ��a2��� ��a2 PHP 6 error_log() ����� &��� ����� ��v�� %�2 &�� �:�� 3���� �-� error log(3 �� �A ,�� 6�� 6 �)A ��>��6 �����
&���� ���"� ��� R�����6#।
������� ��t��q ���������� ��t��q ���������� ��t��q ���������� ��t��q ��� 0���U �����4�0���U �����4�0���U �����4�0���U �����4� <?php //error handler functionfunction customError($errno, $errstr){ echo "<b>Error:</b> [$errno] $errstr<br />";echo "Webmaster has been notified";
error_log("Error: [$errno] $errstr",1," [email protected]","From: [email protected]"); } //set error handlerset_error_handler("customError",E_USER_WARNING); //trigger error$test=2; if ($test>1){ trigger_error("Value must be 1 or below",E_USER_WARNING);} ?> %8����
Error: [512] Value must be 1 or belowWebmaster has been notified &� ���!� ����� &�� &��� ��� ����
Error: [512] Value must be 1 or below
10.
������� �1O�� ����������� ������� �1O�� ����������� ������� �1O�� ����������� ������� �1O�� ����������� ( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)( PHP Fi l t er Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
3�� !�� ������: 8n� 3�� �8"�� ����� �� %�� ��&�'�� ��v�� 6��:� /,��3�(�(validate/acceptable) &��2���6(filter) ����^6 ,�।���� #��� &�?����� &�� ���� (��f�g� ।�������( #��� &�?���� ������ ������� 8�� ��� ����।%��� 3�� ��� #��� &�?���� D6�E ����� 6�� ����� 3��� ��� ��� !�� %��� �� �� ��� filter ��� �������e����� ��" ,��।���� &�� �����o�"��6 ��;�।�!�� ����V 8n� �� %��6 ���� 3��-
• &��� ��� � ������b 6 !��
• W��
• #��� ���� ��� !��
• ��� �� �������
• !����� ������� �����
1�234 �2 �1O��1�234 �2 �1O��1�234 �2 �1O��1�234 �2 �1O�� ��� ����������� filter ���6 ���'� �����(��� ����,�� ��� ,�-
• filter_var() – ���: c &��� ��v�� �:�� &��� ����������� filter ���।
• filter_var_array() – &�� �� ��V ��v�� �:�� &���@� ����������� ��v�� ���।
• filter_input – &��� ��������� ����� ��� &�� ��v�� ���
• filter_input_array – &���@� ����������� ����� ��� &�� &�� �� ��V ��v�� �:�� ��v�� ���। • ���'� 8:�,��� filter_var() function �:�� &��� �g� ����� validate ���
01.<?php 02.$int = 123; 03. 04.if(!filter_var($int, FILTER_VALIDATE_INT)) 05.{ 06.echo("Integer is not valid"); 07.} 08.else 09.{ 10.echo("Integer is valid"); 11.} 12.?>
&� ��!A "FILTER_VALIDATE_INT" ]���$int ����������� ��v�� ����,&���� %8���� "Integer is valid" ���� 123 &��� integer.
VALIDATING VALIDATING VALIDATING VALIDATING �2 �2 �2 �2 SANI TI ZI NGSANI TI ZI NGSANI TI ZI NGSANI TI ZI NG ��v�� G @����
VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:VALI DATI NG FI LTERS:
• user input validate ���6 ����^6 ,�
• ���� ������ ��� :�� ,� (3�� URL �� E-Mail validating)
SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:SANI TI ZI NG FI LTERS:
• &��� ��� & ���: c ��� �Q� ������:� ���� ���� �"�� ����,�� ,�।
• ����� ��� return ���।
OPTIONS OPTIONS OPTIONS OPTIONS �2 �2 �2 �2 FLAGSFLAGSFLAGSFLAGS Option &�� Flag ��� ���: c ��v��� ��6��K filtering option 3�( ���6 ����^6 ,�।����V ��v��� ����V option &��flag %�2।���'� 8:�,��� &�A �g� ������� validate ���6 filter_var() ��v�� &�� "min_range" # "max_range"
option ����,�� ��� ,���2। 01.<?php 02.$var=300; 03. 04.$int_options = array( 05."options"=>array 06.( 07."min_range"=> 0,
08."max_range"=>256 09.) 10.); 11. 12.if(!filter_var($var, FILTER_VALIDATE_INT,$int_op tions)) 13.{ 14.echo("Integer is not valid"); 15.} 16.else 17.{ 18.echo("Integer is valid"); 19.} 20.?>
8���� ���!� �6 options ����� associative array 6 ����6 ,�� &�� “options’’ ���� ����6 ,��।3�: flag ����,����� ,� 6�,�� &�� ����� ,#�� "���� ��।&���� 3�,6� Hqq �g� ����� ��j ���: c ����E��� ��@� �� 6�� &� %8���� ,��"Integer is not valid".
VALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUTVALI DATE I NPUT . �� ���P6 ,�6 ,�� 3 ������b 6 !�� 3�� %��� ��"�2 6�� ��If %�2 ����।6���� filter_input() function ]��� ������b 6 !���� ��v�� ���6 ,��।8:�,�� 01.<?php 02.if(!filter_has_var(INPUT_GET, "email")) 03.{ 04.echo("Input type does not exist"); 05.} 06.else 07.{ 08.if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_ EMAIL)) 09.{ 10.echo "E-Mail is not valid"; 11.} 12.else 13.{ 14.echo "E-Mail is valid"; 15.} 16.} 17.?>
������:8���� 8:�,��� &��� �����(�����) %�2 3� "GET" method ����,�� ��� ��>���� ,���2।
F.'� �� ����� ��������� & "email" 3�� GET � ! ����,�� ��� ��>���� ,���2 ���� ��If %�2 ����।
G.3�: ����� ��������� &� ��If ��� 6�,�� '� �� &�� �R� ����� &�U� ����।
SANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUTSANI TI ZE I NPUT . �� ���P6 ,�6 ,�� 3 ������b 6 !�� 3�� %��� ��"�2 6�� ��If %�2 ����।6���� filter_input() function ]��� ������b 6 !���� sanitize ���6 ,��।8:�,�� 01.<?php 02.if(!filter_has_var(INPUT_POST, "url"))
03.{ 04.echo("Input type does not exist"); 05.} 06.else 07.{ 08.$url = filter_input(INPUT_POST, 09."url", FILTER_SANITIZE_URL); 10.} 11.?>
������:8���� 8:�,��� &��� �����(url) %�2 3� "POST" method ����,�� ��� ��>���� ,���2।
F.'� �� ����� ��������� & "url" 3�� POST � ! ����,�� ��� ��>���� ,���2 ���� ��If %�2 ����। G.3�: ����� ��������� &� ��If ��� 6�,�� sanitize(�.���"�E� �Q��� ��� :��) �� &�� &�� $url variable & ���Q�
��। 3�: ����� ��������� &@���� ��� ,� "http://www.W3ååSchøøools.com/" 6�,�� $url variable sanitizing &�
�� &��� ,��। http://www.W3Schools.com/
� ��\ �4�9�� ��\ �4�9�� ��\ �4�9�� ��\ �4�9� �1O���1O���1O���1O�� �� �� �� �� &��� ��� ��@���6 &���@� ����� ��x ���।&��� &��� ��� ����� call ��� &(���� filter ���� '�� %���
filter_var_array �� the filter_input_array function ����,�� ���6 ����।�3��
view source print? 01.<?php 02.$filters = array 03.( 04."name" => array 05.( 06."filter"=>FILTER_SANITIZE_STRING 07.), 08."age" => array 09.( 10."filter"=>FILTER_VALIDATE_INT, 11."options"=>array 12.( 13."min_range"=>1, 14."max_range"=>120 15.) 16.), 17."email"=> FILTER_VALIDATE_EMAIL, 18.); 19. 20.$result = filter_input_array(INPUT_GET,$filters); 21. 22.if (!$result["age"]) 23.{ 24.echo("Age must be a number between 1 and 120.<br />");
25.} 26.elseif(!$result["email"]) 27.{ 28.echo("E-Mail is not valid.<br />"); 29.} 30.else 31.{ 32.echo("User input is valid"); 33.} 34.?>
11.
���������������������������� 0���0���0���0��� 1�2341�2341�2341�234 ( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)( PHP Mai l Funct i on Tut or i al i n Bangl a)
��� ��:�"#����� %��
%��� PHP mail() ����� ]��� ������ #��� �" �� ����� ��>��6 �����। ����6 1.mail(to,subject,message,headers,parameters)
���������������������������������������� �� ���� ���� ���� ��
to "����।&���� 3 ����� R���� ���� �� R����� ��� 3���।
subject "����।&���� ��;� 8�d� ����।
message "����।&���� ���" ���� 3� ��>���� ,��। ����"� ����(��� (\n) �'[ ]��� �b � ,�� &�� ��� ���� wq �Q���
headers p�-�।&� ]��� ��6��K �������� 3�( ��� 3���। 3��:From,Cc,Bcc.
parameters p�-�।��6��K ���������� 3�( ��� 3��।
���:��� ����� ��3 �� ���� "�� %���� ������ ����� ��� �� ���� ���6 ,�� &�� php.ini ����A �� ���3��E ����(����� ���6 ,��>>��7�6 ����� ,�-?��=6 ,#��� :���� ��-%����� ��2�� ���6 ,����।���� %��� 3�� ,���� .����!����
���2 %���:� ����(��� ,���� ���� 6��:� ��� ��� &�� ���� ���।&�� �� %��� ��@� ���'� �� W ��� ��� �u��। @��� %���� &��� A8�������� ���� %�2 &�� .�6A A8���������� �� �<�� ���� ����}� %�2 %� %��� '��-� 3 �<��(���%���� ��� R����� '�� %��� 3��6 ��7�6 ����� %���� A8�������� A �6"��� ���2 ��� �� ����� ��(�2।� ��n ��!������ ।&�� ���� "�� ��&�'�� ��� �����।���'� 8:�,��� &�A �M� ���" ��>���� ,���2 p ���� 3� �����2
(� ��n [email protected] &� ����)
PHP MAI L FORMPHP MAI L FORMPHP MAI L FORMPHP MAI L FORM <html>
<body> <?php if (isset($_REQUEST['email']))//if "email" is filled out, send email{ //send email$email = $_REQUEST['email'] ;$subject = $_REQUEST['subject'] ;$message = $_REQUEST['message'] ;mail( " [email protected]", "Subject: $subject",$message, "From: $email" );echo "Thank you for using our mail form";} else //if "email" is not filled out, display the form{ echo "<form method='post' action='mailform.php'>Email: <input name='email' type='text' /><br />Subject: <input name='subject' type='text' /><br />Message:<br /><textarea name='message' rows='15' cols='40'></textarea><br /><input type='submit' /></form>"; } ?> </body> </html>
�o��o��o��o�:::: . �� :� 3 ����� &� a�A ���� ����2 ����
3�: �� ��� 6�,�� HTML �� A� :��# 3�: ���� ��� 6�,�� �� �� !�� ���� ��� ��R�� :�#
&� HA logic &���� ����^6 ,���2। &��� 3�� �� ���� ��� ������ ����� �L� ���� 6�� �"A reload ,� &�� 3�� :�� ����� &� a�A ���� ����2 6�� ���
��R�� :�।
����������������::::��� �4���r ���j 4� ��j �� �� 1�R �t�� �� ��\ ��U�� 0��� �� �r�j ���� ��� �4���r ���j 4� ��j �� �� 1�R �t�� �� ��\ ��U�� 0��� �� �r�j ���� ��� �4���r ���j 4� ��j �� �� 1�R �t�� �� ��\ ��U�� 0��� �� �r�j ���� ��� �4���r ���j 4� ��j �� �� 1�R �t�� �� ��\ ��U�� 0��� �� �r�j ���� ���� �� ����� �4�U 34।����� �4�U 34 0g� ���� ���� t� ���� �� ����� �4�U 34।����� �4�U 34 0g� ���� ���� t� ���� �� ����� �4�U 34।����� �4�U 34 0g� ���� ���� t� ���� �� ����� �4�U 34।����� �4�U 34 0g� ���� ���� t� form validationform validationform validationform validation....q� q� q� q� PHP PHP PHP PHP �1O�� �1O�� �1O�� �1O�� ((((FilterFilterFilterFilter) ) ) ) �2�3� ������������ 4R4� ���v�2�3� ������������ 4R4� ���v�2�3� ������������ 4R4� ���v�2�3� ������������ 4R4� ���v
CCCC....������������� 0P�Q�� R����� 0P�Q�� R����� 0P�Q�� R����� 0P�Q�� R 1.1.1.1. ������� 0P�Q�� R ����������������� 0P�Q�� R ����������������� 0P�Q�� R ����������������� 0P�Q�� R ����������� � � � | | | | ���� � ���� � ���� � ���� � ( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i( PHP Fr amewor k Tut or i al i n al i n al i n al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
• ��&�'�� O�#$�� (PHP Framework) ,�- &��� basic Platform/structure((>�) 3�� #�$� ����?����
D6�E�6 ����^6 ,$। • ��(� �e�6,������ like ����� �L� ���� :��� &� ��� A �6"� �2Z (like) ����2,.�6��� �" �6� � ��� ��!
,��� �� ������ &� ����6 � �6���: &(��� &� &�A &�?������ &� 8:�,��। • PHP Framework ����,�� ��� %��� &�?���� D6�E� ��� 3 ����@�(���� �����-.'�� ��$ ��'��,������ ��! D6�E
���� 7����� �� ���K,C6 ����?���� D6�E ���6 ������। • &2�N� !������� ��� ���3�( &� ������A# �," ��� 6���,&(���� 2�N�# %�# ���� ����@� %�2 ,��" ���� ����� ��7�6
������।
�," � �$ ��&�'�� O�#$�� (PHP Framework) &�� &�A ���#$��� 3�� ���� �:�� %��� ��� �,�"� &��� #�$� ����
D6�E ���6 ������ ���� &���� %�( ��� ���� ��! D6�E ��� ���। ��&�'�� O�#$�� (PHP Framework) ���� %�( 3 ��;$(��� ��������� "���6 ,��
F.PHP(����; ��� PHP Function, Variable etc)
G.Object Oriented Programming
H.MVC(Model View Controller)Structure
���� ��&�'�� O�#��� %�2 3�� "� O�#��� ,��,���,������,��!�(������ �6���:।�"� &�� ��!�(������ ���'�� ���"��.� 6�� ������ "� &� ��" ��� �� �R�-"� �:�� &���.��" ��&�'�� &� ��" ��� 3��।6�� . �� ����#��� ���O�#��� �:�� ��" ��� ���� ��� 8�'n 3�� ��!�(������,��,��� �6���:।&���� %�� ��!�(������ (CodeIgniter PHP
Framework) &� 8�� ��2� �~��� @���� :$�� 'c� ���।
2.
��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ��UV ������K�� 0W�X���2 �2 ������� ( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)( OOP & PHP Tut or i al i n Bangl a)������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
W������ ������K��W������ ������K��W������ ������K��W������ ������K�� 0W�X���20W�X���20W�X���20W�X���2---- POP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENPOP ( PROCEDURE ORI ENTED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG)TED PROGRAMMI NG) 8'� �3 ���� language 3�� FORTRAN(Formula Translation-&�� Statistician �� ����,�� ���
���)COBOL,C �6���: ����,�� ��� (6���(�6� �� �������� ����� 3�� .�/���� ��� ,� 6��� ��@���6 ��� ,� Procedure Oriented Programming(POP).PHP �:��# &���� .�/���� ��� 3��।POP (R6 ,� ��2� ���: ����
(instruction/actions) 6����� ����,&� ���: ���(��� ��+8����� "��।&� ���: ���(����� �� %���� ����I ����� ����� ����
����'6।&��� �u .�/���� &���� 2�� 2�� ���� ��( ��� ,�,.�6A ���� &��� .�/�� &�� &���� �����+!�� ���। ����� ,� &��� �u .�/��� ��� !��� "�� ��� ����� ����,�� ����2� &�� �� ��� �c�� &�� ����� .�/����� %������ �u�6,�।3���,�� %��� ��2� ����� %�2 POP 6 3�� ����@����6 ��� global data %5�< ,�� 3�6 ���� ��� �������
����6 ��� ����� &�� %�# ����� %�2।
��UV ������K�� 0W���UV ������K�� 0W���UV ������K�� 0W���UV ������K�� 0W�X���2X���2X���2X���2---- OOP( OBJECT OOP( OBJECT OOP( OBJECT OOP( OBJECT ORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NGORI ENTED PROGRAMMI NG)))) OOP �� ���"X �������! .�/���� (Object Oriented Programming) &� �����(���� ���@��� ��2� ��K���E @���� ����&���2।OOP !���� critical element �,���� ����'�� ��� &�� ������ !��� ��K .��, (free flow) �t ��� :�।OOP &� �� &���@� Objects ���� (R6,&��� ����� ���@���� "�� &� ���"X(��� &�A %���A� ��� 3�(��3�( ���/�� �)�����/�]���Q� 6 � ������ ��� ��� 6��� /(interact)
OOPOOPOOPOOP *&�� !���� ������� ��� ��� �K���� @�� ����(3 ������� &� !���� operate ����)
*�u .�/�� Object %���� ���K ���।� ��n &��� .�/��� 2�� 2�� ���� ��( ���� 3� Object
*&��� Object & !�� &�� ����� ����,&� �����A !���� '����� (Operate ����)
*������ ��� ����� &� !���6 &���� ���6 �������।
*����� ]��� &��� Object %����� Object &� ��� 3�(��3�( ���6 ����।
*&��� .�/��� 3���� ��� �6� � !�� &�� ����� 3�( ��� 3���। OOP ����6 3(����� @���� ���h�� ���6 ,��
• Objects
• Class
• Encapsulation
• Inheritence
• Polymorphism
• Message passing
��UV ��UV ��UV ��UV ( OBJECTS)( OBJECTS)( OBJECTS)( OBJECTS) ���"X D6�E ,� ��2� !�� &�� ��! ����,&� ��! !���� ���������� (��������� ���'���� ���) ���।���"X ,�- &��� (�2�� �6(a bundle) 3� !�� &�� ������� ����� D6�E।&��� ���M� � � ����� ,�� 2�� �� �u ��M।&��� ���"X &��� ���M� �6,���M
3�� ��2� �"��� ��� 6��� ���"�X# ����� ����,��! ����।���Q�� ���"X ,�- ��2� ��&�'�� ���!� ��u�।���"X :��6
������ ������� �6(���!� ��@�)।কিন্তু &�� ���� ��#����� � ������� '��। ���"X �������! ��&�'�� 6 %��� 3���! (��� :�� %��� &(��� ��2� ���"X &� (�2�/ ���/6�u� (bunch).&��� ��/ ��������@���� "�� &� ���"X(��� &��` ��" ���।&��� 8:�,�� ,�6 ���� &��� ��� ��� (��&�'��� ��� �)*A), 3���� %�2 &�(�-�� &�� ��� (bunch) �� '��E (���"X(���),6��� ��� ���� &���� ��" ���,3���� .�6�� �� '��E (���"X) ���" ���"� ��"
���� ���� �+�:� ��� 469����। L���� ��&�'��(�������� �e�6-Procrdure Oriented way) &� ��� 3�: 6� ��� ���� 6�,�� :���� ����� �������
���(bunch) ���� �)�*� 2u���� ��� '�� �� �� '��।
8�� 8�� 8�� 8�� ( CLASS)( CLASS)( CLASS)( CLASS) ��&�'�� 6 ���"X D6�E� %�( %����� &� ���"X &� "�� &��� ����/&��� ����{��
(blueprint/template/outline)D6�E ���6 ,��।&��� ���?��� (&��� ���"X &� "��) L�� ���। L�� ,�- ���"�X� "�� ���� (blueprint).&��� L�� ,�- ���"�X� "�� �� ��। 3�� &��� �����6 &��� ���x� &� �� �� ���।&��� L��� ��2� ���" ���� 3�� �������,����� � ��n &��� L��� &��� ���"X �+�� @���� ����।3��� &������"X �������! ��&�'�� ��! ��� ����� 6�� ��&�'�� &��� living,breathing ���"X D6�E ���� L�� &� 8�� ���o
���।living,breathing ���"X ���6 ��7���� ,�- &� ���"X A ��� �� �����6 D6�E ,�।
�4 �����34 �4 �����34 �4 �����34 �4 �����34 ( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON)( ENCAPSULATI ON) &��� L���� (class) &� ��@� !�� ������ ���� &����� &����������� ���।&�� L���� &�A ��K���E D���c�।&�6 ��� L������6��� !���6 ����� �� &���� ��#�� 3����।� ��n ������ ��� ����� &� !���6 .��� ����6 �������।��@���` 3�: &� L������6��� ��� ����� ��� 6�,�� �� �����A� ��@� &� !���6 &���� ���6 �����।������ ����� �� !��� &� &���� �t ,��3�#��� .�5��� ��� !�� ������� �� 6 � ������� (data hiding/information hiding)
�4�t����� �4�t����� �4�t����� �4�t����� ( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE)( I NHERI TANCE)
OOP 6 ���,����S ��! �g�:����,���� (reusability) @���� .:�� ���।� ��n &��� L��� ��6��K ��2� 3�( ��� 3�6 ����L��A�� �:����� 2�u��।@��� %���� �)�* &��� L�� %�2 &�� %��� %����� �6�� L�� D6�E ���6 ����� &� L�� �@E��।���L�A�� ��� ,� ����� L�� �� �� L�� (super class/base class)%� 3 ���� L��(��� &��� �� �� ,�� �(���
���L��/.�6���:6 L�� (subclass/derived class).extends &� ��#��! A �:�� �� L�� �� &�A �6� � L�� �� ��� 3��।
������1U� ������1U� ������1U� ������1U� ( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM)( POLYMORPHI SM)
&���@� ���"X &� "�� &�� ����� ����,�� ��� 3�� ����V ��" ��� ,� 6�� &� .�5���� ��� �������"�।
0���U ��j��4 0���U ��j��4 0���U ��j��4 0���U ��j��4 ( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG)( MESSAGE PASSI NG)
&��� OO Program & &���@� ���"X ��� &�� &�� &� ����� ��� 3�(��3�( ��� ��� � ��n &��� ���"X %�����
���"X &� ���2 ���" ��>�� &� .�5��� ,� ���" ��65��।
3.
�[�[�[�[ \���\���\���\��� ��UV��UV��UV��UV ������K��������K��������K��������K�� ���������������������������� ( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)( OOPHP Tut or i al i n Bangl a)
�����1 1���������1 1���������1 1���������1 1���� ���4���� ��j ����4। 0���R 0 � ��j ����4। 0���R 0 � ��j ����4। 0���R 0 � ��j ����4। 0���R 0 ����� �o��4 �6 ���� ��&�'��� n (PHP5) ��� � '��2।��&�'�� n �+g� ���"X �������!।&� %�(� ��� � ��&�'�� l �+g� ���"X�������! �2���।��&�'�� n ���"X �������! ,#���6 &�� �:�� "A�,�������,���3�(�,�!� ���� #��� &�?���� D6�E �," ,��
(�2।OOPHP ��! D6�E� %�( %���� ��&�'��� �����,�������,������� �����,��� �6���:� @���� ���6 ,��।
A8��������A�� �," &�� D@3 � @�� ����6 ��� GH A 2�� 2�� ����(@���) ��( ��� ,���2।
\��\��\��\��---- ^:^:^:^:
Wg�� Wg�� Wg�� Wg�� ������ ������� 0�U ij�k �4�� ������� 0�U ij�k �4�� ������� 0�U ij�k �4�� ������� 0�U ij�k �4
index.php
class_lib.php
%���:� ���"X �������! ��! &��� ����� ���� �� ����A %��� ��&�'��� ‘includes’ ����� ����,�� ��� ��&�'���&��� ����� ��" i� ���� :�।&� A8���������� "�� %���:� �� ���"X �������! ��! class_lib.php ����� ����।OOP
%��� L�� D6�E� ������A� ��� "�u6।L�� ,�- �+�?�/W�� ����� ���"X� &� "�� 3� p ���"X �+�� @���� :�।
\��\��\��\��---- �:�:�:�:
� �� � �� � �� � �� ������� 8�� ij�k ��������� 8�� ij�k ��������� 8�� ij�k ��������� 8�� ij�k ��
��&�'�� �)�* �����,��!,������� �6���: 2�u�� �2A�� ����� �����6 3��� %��� ���"X �������! �e�6�6 ��! ���� 6��
. ��� &��� L�� D6�E ��� ���6 ,��।L�� D6�E� "�� . ��� ‘class’ �0A �:�6 ,�� &�� &��� L���� ��� ��-�6 �:�6 �����। 1.<?php
2.class people{
3.
4.}
5.?>
\��\��\��\��---- [:[:[:[:
8��� 0��� 0q�a ��8��� 0��� 0q�a ��8��� 0��� 0q�a ��8��� 0��� 0q�a ��
L�� ,�- ���"�X� "�� ��.�/����।3�� L���� ��6� %��� &��� ������� D6�E ����� 6�� &� ��������� ��� ,��‘property’ 1.<?php
2.class people{
3.var name;
4.}
5.?>
������������: &��� L���� ��6� 3�� !��/������(&� 8:�,��� var name;) ���� ,� 6�� &���� ��� ‘properties’
\��\��\��\��---- �:�:�:�:
8��� 1�2348��� 1�2348��� 1�2348��� 1�234////0�g� 0q�a ��0�g� 0q�a ��0�g� 0q�a ��0�g� 0q�a ��
&��� L���� ��6� &��� ������� ����� 3�� ���� ��� ,�� 3�� ‘properties’ 6��� &��� L���� ��6� &���
������� ����� 6�� ��� ,�� 3�� ‘methods’ (�� ���6 ����� L���� ��6� ����� 6�� &�:� &� ���� !��� ,� )&���
L���� � !/methods �� L���� !��/properties � ���������� ���6 ���^6 ,�।
<?php
class people{
var $name;
function set_name($new_name){
$this->name=$new_name;
}
function get_name(){
return $this->name;
}
}
?>
L���� ��6� ��������� properties ��� &�� ��� ����6 ,��।
\��\��\��\��---- `:`:`:`:
getter getter getter getter �2 �2 �2 �2 setter setter setter setter 1�2341�2341�2341�234
%��� :�A �����/� ! D6�E ����2 get_name() &�� set_name() &� ����(���" &�A �E�6 ��� '�� 6�,�
&��� L��� getter &�� setter ��� ����� property ����� ��� �����।
<?php
class people{
var $name;
function set_name($new_name){
$this->name=$new_name;
}
function get_name(){
return $this->name;
}
}
?>
&���� �Q� ���� getter &�� setter ��� property ����� ��� �����2।&�6 ��� 3�� ��� ��&�'�� .�/����
%���� ���"X ���� ��" ���� 6�� 3���` � %���� set_name() �����/� ! :��� 6��� � ���7 ��� 3 &����
����� &��� property/variable ���� 3��� ��� ,�� ‘name’
\��\��\��\��---- �:�:�:�:
‘$t hi s$t hi s$t hi s$t hi s ’ 0������0������0������0������
���! ���6 ���'� ����A :���2�
$this->name=$new_name
$this &��� ��v�� ������� (�� ���"�X� &�� ��v ��)3�� �6 ��� ���"X�� ���: � ���।���� �� &�� &��� self-
referencing �������।&�� ���,�� ��� properties & &���� ��� 3�� &�� &��� � !�� �6 ��� L��� �� ���
3��।
function get_name() {
return $this->name;
}
��7�6 3�: ����� ,� 6�,�� &�� ����� 3 &�� &��� ��&�'��� ��#��! &�� 3�� ��&�'�� ���! &� ������� ��� 6��
��&�'�� ���"� ���7 6��� �� ���6 ,��।
\��\��\��\��---- �:�:�:�:
�9� ������� 0��U �� 8�� �9 ��4��9� ������� 0��U �� 8�� �9 ��4��9� ������� 0��U �� 8�� �9 ��4��9� ������� 0��U �� 8�� �9 ��4�
��� ��&�'�� ��" ������ &� L�� �������� 6�,�� ���"X �������! .�/���� &� 8�B��� �� ,��।���'�� ��� ,� L��
%��:� &��� ��&�'�� ��" D6�E ��� ��� ��&�'�� ��" &�� ‘include’ �� ‘require’ �:�� 3�( ��� :��।
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transi tional//BN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona l.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UFT-8" />
<title>OOPHP in Webcoachbd</title>
<?php include("class_lib.php"); ?>
</head>
<body>
</body>
</html>
%��� ��j &��# L�� �:�� ��2� �����,&��� ���� ,��।
\��\��\��\��---- �:�:�:�:
��UV ij�k ����UV ij�k ����UV ij�k ����UV ij�k ��
&��� L��� ���"X D6�E� .�5���� ��� instantiation.
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
</body>
</html>
$rejoan ������� �6� � D6�E people ���"X &� "�� �����S।%��� $rejoan ����,�� ��� &� people
���"X�� ���9� &�� ����,�� ���� "��।
\��\��\��\��---- �:�:�:�:
newnewnewnew � Q���R� Q���R� Q���R� Q���R
&��� L���� ��6� ���"X D6�E ���6 %���� &� new ��#��! A .���"� ,��।
%��� ��- ���� &��� L��� ���� ���"X D6�E ���6 �����।��&�'�� ���"��� ���2 .�6A ���"X %��:� %��:� (469
4o�)
<?php include("class_lib.php"); ?>
</head>
<body>
$rejoan = new people();
$riad = new people;
</body>
</html>
���"X D6�E� ��� L���� ��@� quote �:����� 6�,�� �� � ,��।� ��n ���'��� &��� �� �
$rejoan= new 'people';
\��\��\��\��---- ^�:^�:^�:^�:
��UV ��UV ��UV ��UV properties properties properties properties �� �� �� �� ((((setsetsetset) ) ) ) ��। ��। ��। ��।
%��� :�A ���"X D6�E ����2 people ����,&�� %��� 6��:� properties R� (set) ��� �:�6 ���� p
� !A(the setters) ���,�� ��� 3�� %�( D6�E �����।
&�� ��� ����6 ,�� 3 3�:# %���:� ���"X &���� GA($rejoan &�� $riad) &�� L�� people &� 8�� ���o
��� D6�E ��� ,���2।��&�'�� ��j 6��:� �+g� %��:� �,���� ����'�� ���� � ��n ��&�'�� &���� GA ���"X :��� 3� �+g� %��:� %��:�।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people();
$riad= new people;
$rejoan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
?>
</body>
</html>
\��\��\��\��---- ^^:^^:^^:^^:
��U�V� 0����j � ��� 04����U�V� 0����j � ��� 04����U�V� 0����j � ��� 04����U�V� 0����j � ��� 04��
&�� %��� getter � !A ���,�� ��� ���"�X� !���6 &���� ���6।&�� ,� �� !�� 3� %��� setter � ! �:��
���"�X i� �����2���।
3�� %��� L���� � ! &�� properties & &���� �� 6�� ������(->)�'[A ����,�� ���।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people();
$riad = new people;
$rejoan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
echo "Riad's full name: " . $riad->get_name();
?>
</body>
</html>
���:&� ������ (->) �'[ %� &�������A� ������ (=>) &� �'[ ��j &� ��।
����Z� %��� &� A8���������� ��@ � �; ��� �����।
3� 3� ������:
&��� ��&�'�� L�� �!"��� �����
&� L���� 8�� ���o ��� &��"�u� ���"X D6�E �����
���"�X !�� i������
���"X �� !�� 6� �� %����
@��-FG:
������ ��UV ������ ��UV ������ ��UV ������ ��UV properties properties properties properties � � ��� 04��� � ��� 04��� � ��� 04��� � ��� 04��? ? ? ? ��� ��44���� ��44���� ��44���� ��44�
���"�X� properties & &���� ��6 %����� ��� � ! ���,�� ���6 ,����,%��� ������ ������ (->) �������
����,�� ��� &���� ���6 �����।8:�,��4���:
$rejoan->name.
3�:# &�� ��� 3�� 6��# &�� �� ��� ��� ���� &�� &��� ���" �e�6।&���� ���� ��7���� �(�� ����� ,�6 ����।���'�� ���
,� getter � ! ���,�� ���।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people();
$riad = new people;
$stefan->set_name("Rejoanul Alam");
$riad->set_name("Anjirul Alam");
// directly accessing properties in a class is a no -no.
echo "Rejoan’s full name: " . $rejoan->name;
?>
</body>
</html>
\��\��\��\��---- ^[:^[:^[:^[:
4d�V� 4d�V� 4d�V� 4d�V�
�� ���"�X� &��� ��v�� � ! %�2 6�,� ����X�।&�� %����� ���"�X� properties &� ��� :��।
������������:__construct() ����� A D6�E ���� ��&�'�� ������A� __construct �����/� !�� �� ��� 3�� %���
&��� L���� ��6� &��� ���"X D6�E ����।
‘construct’ � ! :�A %����T�� (__)�:�� ���� ,�।����X � �!� �� L�� ��� &�� 6���� ��2� 3��K� 6�����
(&��� ������� �6) �:�� ��@���6 &� � !�� ��be ��� ,�� ���।
<?php
class people {
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
&� A8���������� ������Q�6 ��� ������
functions=methods
variables=properties
@��-Fl:
construct construct construct construct �r�� � �� ��UV 0j�k ���r�� � �� ��UV 0j�k ���r�� � �� ��UV 0j�k ���r�� � �� ��UV 0j�k ��
%��� &��� ����X� � ! D6�E ����2,&�� %��� people ���"X D6�E� ��� $name property’� ��� �:��
�:�6 ����।8:�,��:
$rejoan = new people("Rejoanul Alam");
&�� %���:��� set_name() � ! �� ��� �� ���'�� :��।&�6 ��� ���!� ������ �)�* ��� 3���।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoan’s full Name: " . $rejoan->get_name();
?>
</body>
</html>
&�� &��� 2�� 8:�,�� 3���� :�� (� ���"X �������! ��&�'�� &� ��v�� �~�� (mechanism) ������ ���!�
������ ����� :�।�� ��! �� �� � &� �E�6।
\��\��\��\��---- ^`:^`:^`:^`:
properties properties properties properties � � ��� ���1���� t�� �� � ��� �k��� ��।� � ��� ���1���� t�� �� � ��� �k��� ��।� � ��� ���1���� t�� �� � ��� �k��� ��।� � ��� ���1���� t�� �� � ��� �k��� ��।
���"X �������! .�/���� &� &��� ����E�6 ,� &���������� (encapsulation).&�� %���� ���"�X� !�� ���'��
(properties) & &���� �E���e ��� :�।
L�� properties & &���� �E���e ���� "�� ‘access modifier’ ���,�� ��� ,�।HA &���� ��!����� %�2-
1. public
2. private
3. protected
�!�v �,���� public ���।
<?php
class people {
var $name;
public $height;
protected $social_insurance;
private $pinn_number;
function __construct($people_name) {
$this->name = $people_name;
<i>} </i>
function set_name($new_name) {
$this->name = $new_name;
}
function get_name() {
return $this->name;
}
}
?>
���: ‘var’ ��#��! �:�� ��� properties a�;�� (declare)���� 6�� &���� ‘public’ �,���� @�� ,�।
@��-Fr:
properties properties properties properties � � ��� �k��� ��।�23� � ��� �k��� ��।�23� � ��� �k��� ��।�23� � ��� �k��� ��।�23---- ����
3�� &��� property � private a�;�� ��� ,� 6�� ��@� ����� &�� L�� &���� ���6 �����।
3�� property � protected a�;�� ��� ,� 6�� ��@���` &�� L�� &�� .�6���:6 L�� (derived class/&�
L��A p L�� �� .�6���:6 ,#�� L�� 3 L��A� properties & &���� �2�) &� :�A L�� ����� &���� ���6
�����।���"� � �� &�� L�� &�� p .�6��:6 L�� 3� �� L�� �� �� ,���2।
public ���� ��� �E���e6� �� 3��8 �)�*� 3���� "��(� �� &�6 &���� ���6 �����।
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
$rejoan = new people("Rejoanul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
/*
3�,6� $pinn_number � private a�;�� ��� ,���2� 6�� &� ���! &��� �� � ,�� (�, .�/�� ��� ������ :��6
�����।��� ����� :���।
*/
echo "Tell me private stuff: " . $rejoan->$pinn_num ber;
?>
</body>
</html>
\��\��\��\��---- ^�:^�:^�:^�:
0�g�� � ��� �k��� ��0�g�� � ��� �k��� ��0�g�� � ��� �k��� ��0�g�� � ��� �k��� ��
properties &� �6 � �!# %��� &� HA &���� ��!����� ���,�� ��� &���� ���9� ���6 �����।
1. public
2. private
3. protected
%��� �� &���� ��!����� ���,�� ���?
8o�:���� &�6 %�� &�� R� ��� �:�6 ����� 3,%��� D6�E ��� L��A ��� ��&�'�� .�/���� ������ ���,�� ����।&�
@���� �� &��� (��f�g� 6 � ����� %�� 6�,� &��� �u .��"�X &���� ���� ��&�'�� .�/���� ��" ���6 ����� &��
6�� ���# ,�� ���।
<?php
class people {
var $name;
public $height;
protected $social_insurance;
private $pinn_number;
function __construct($people_name) {
$this->name = $people_name;
}
private function get_pinn_number() {
return $this->$pinn_number;
}
}
?>
���:3�,6� get_pinn_number() &A private 6�� &� � !A ��@���` 3 L��� %�2,p L�� �� ���,�� ���
3���।3�: �)�*� ��� �� �# �� &� � !�� �� ���6 '�� 6�,�� public a�;�� ���6 ,��।
\��\��\��\��---- ^�:^�:^�:^�:
0 �� ��40 �� ��40 �� ��40 �� ��4::::t��t��t��t��::::�4�t������4�t������4�t������4�t�����
���"X �������! .�/���� & ���,����S (Inheritence) &��� �~��� D���c� 3�� ]��� %��� &��� L���� ���
L��/L��(���� �� L�� �,���� ���,�� ���6 �����।
�� &�� ��� ,�?
8o�:&� ]��� %��� �� L���� ��!�� �g�:����,�� ���6 ������।@��� %��� &��� �6� � L�� D6�E ���6 '��-� 3�� ���
‘employee’ 3�,6� employee &� @���� people/person 6�� 6��� &�� � ! &�� properties
���� ����।
&��� @���� D6�E ,���2 6�?
&� @���� ��}�� ���,����S %���� ��!�� ����� :�� &�� 7�7�� ��� 6� ��� ���� %��� &�� ���!� �g�:���,��
���2� :�A %��:� L���।��j &�� �������� �e�6� ��&�'�� ���!� �6 ��।
F. ����� �)�* %����� ��@� &���� ��!(��� ���� ���6 ,��।
G. 3�,6� %�� ��! �g�:���^6 ,�- 6�� &�� ���� (�����) L��� ���^6 ,�6 ���� ��j ��!(��� ���� &����� ���6
,��।������ ��&�'�� ‘includes()’ &� �6 ��"�� ,��।
// 'extends' &� ��#��! A ���,����S � �'� ���।
class employee extends people {
function __construct($employee_name) {
}
\��\��\��\��---- ^�:^�:^�:^�:
0 ���� 0 ���� 0 ���� 0 ���� ��4��4��4��4::::t��।�23t��।�23t��।�23t��।�23---- ����
3�,6� employee L��A �� L�� people �� �� ,���2 6�� employee L��A ������A� people L����
��� ‘public’ properties,� ! &� L�� ��� 3���(� �� ���6 ����� &� L���� ,�� 3���)।
// 'extends' &� ��#��! A ���,����S � �'� ���।
class employee extends people {
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
�Q� ���� ������ employee L��� set_name() � ! ���,�� ��� 3�:# &� � !A employee L��� a�;��
(declare) ��� ���।���� &� � !A ��6���@� %��� people L��� ���,�� ����2।
@��-Gq:
0 �� ��40 �� ��40 �� ��40 �� ��4::::t��।�23t��।�23t��।�23t��।�23---- [[[[
���'� ���! :��� %��� employee ���"�X get_name() � ! ���,�� ���6 ���� people L���� �~"���।&��
&��� �������� �e�6� 8:�,�� 3���� ��! �� ��� ,� (&�� �����/� ! :���� ��� ,���)
<title>OOPHP in Webcoachbd</title>
<?php include("class_lib.php"); ?>
</head>
<body>
<?php
// Using our PHP objects in our PHP pages.
$rejoan = new people("Rejoanul Alam");
echo "Rejoan's full name: " . $rejoan->get_name();
$riad = new employee("Anjirul Alam");
echo "Riad’s full name " . $riad->get_name();
?>
</body>
</html>
\��\��\��\��---- �^:�^:�^:�^:
0�g� 0�g� 0�g� 0�g� Over r i ddi ngOver r i ddi ngOver r i ddi ngOver r i ddi ng
���7 ���7 (3�� ���,����S ���,�� ��� ,�) &��� � ! �� L�� �� ������ ��" ���� &�� ����6 � ���� .���"� ,�6
����।
8:�,��4��� @��� set_name() � !A people L��� 3� ����2 6� �� ��V ��2� employee L��� ���6 ,��।
%��� ��j people L���� set_name() � ! Override ����2� employee L��� &� &�� � !A a�;��
���।
<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' &� ��#��! A ���,����S D���c� � �'� ���।
class employee extends people {
protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>
�Q� ���� set_name() � !A people L��� (�� L��) ������ �2� %� ������ ��V���� employee L���
������ ,�।
@��-GG:
0�g� 0�g� 0�g� 0�g� OverridingOverridingOverridingOverriding....�23�23�23�23---- [[[[
���# %���� �� L���� � �! &���� ��� ��(�6 ����,3� � !�� �� L���� ��� .�:���:6 L��� (&���� child L��#
���) override ����2�।
���'� 8:�,��� %��� employee L��� set_name() � !�� override ����2 &�� %��� ��! &���� ����
people::set_name($new_name);
&�6 parent L���� (People) set_name() � �! %��� &���� ���6 ����।
<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' is the keyword that enables inheritanc e
class employee extends people {
protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
else if($new_name == "Anjirul Alam") {
people::set_name($new_name);
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>
\��\��\��\��---- �[:�[:�[:�[:
0�g� 0�g� 0�g� 0�g� overriding overriding overriding overriding �23�23�23�23---- [[[[
'people::set_name()' &A ��&�'�� ���"��� ��� 3 6� �� people L��� set_name() � !�� ���" ��
��।
%����� �� ��� �e�6 %�2 3���� %��� parent ��#��! A ���,�� ��� �6 ��� L���� parent L�� (�� L����
parent L�� ��� 3��) � ���: � ��� �:�6 �����।
<?php
class people {
// explicitly adding class properties are optional - but is good practice
var $name;
function __construct($people_name) {
$this->name = $people_name;
}
public function get_name() {
return $this->name;
}
//protected methods and properties restrict access to those elements.
protected function set_name($new_name) {
if (name != "Jimmy Two Guns") {
$this->name = strtoupper($new_name);
}
}
}
// 'extends' is the keyword that enables inheritanc e
class employee extends people {
protected function set_name($new_name) {
if ($new_name == "Stefan Sucks") {
$this->name = $new_name;
}
else if($new_name == "Anjirul Alam") {
parent::set_name($new_name);
}
}
function __construct($employee_name) {
$this->set_name($employee_name);
}
}
?>
03� g�03� g�03� g�03� g�:::: ���"X �������! .�/���� &� &�:� �~��� ��;���: %��� ���� (���।&��� OOPHP &� "(�6 ����� %(���� %����
"�� ���� �," ,�� (�।&�� OOP 6 %���� :Q6� �b�e� "�� &��� ����� �:�6 ���� 6�,� &��� ��! ������
����,��! ���� �"� ���6 �����।�3�� �6� � �6� � ���"X D6�E ���� %��� &�� �:�� ����V @���� ��" ���� 'c�
����।&@���� z/Fq A ��! D6�E ���� &�6 ��� :���� ���"X %� L���� ������(��� �6 �," ,�� (�2 %���� ���2।
OOP OOP OOP OOP �2 ?�4�� 0W�X���2�2 ?�4�� 0W�X���2�2 ?�4�� 0W�X���2�2 ?�4�� 0W�X���2 ������ ������ ������ ������ ���"X �������! .�/���� ���#��� D6�E� &��� %@���� �e�6।��@���� ����(���" &�� &� � ! ���,�� ���2।�3��
"���,��&�'��,����,��++ �6���:। 3�,6� ���#��� D6�E� ����(���" (��� ���"X �������! 6�� &�� ����� %��� 3���� ��� p�� ����(���" & ���' ���6
������।3�:# �6 ���� !T�� ��! &�?���� !�������:� (���#��� !������) '�� #��� ��! &�?���� !��������
(#��� !������) ��� ���� ���2।3���,�� OOP &� ������� �; 3 8����A� � � ��� 6�,� 3�� %��� ���"X
�������! ��&�'�� ��! ������ 6�� ���6s�6 p ��! ������� &�� %��!� ��� �," ,��।
%� &��� � � &�� &��� �;,%��� 3�� �u ��� ��&�'�� .��"�X ��" ����� . � ��}�� &�� %���� "�� &��� '�����"
,�� :�u��� ���� %����� ��V &��� ��I�� �'<� ���6 ,��।����� .��"X �� %����� ���"X ���� ��� %���� @�����6
%��6 ,��।&"�� ���"X ��! .��"X !���� ���� ��� %�( ���� �� !���/�� %�W�।!���/�� %���� ��2� A��-
Ø ����� # ��(" ���,�� ����।
Ø .�6A ���"X�� ���.�"� ���� "�� ��M %W�
Ø &� ��M(�����6 � ! &�� properties &� 6����� D6�E ����
Ø ������ &�� ��� ���,�� ���� ���"X(���� ��@� �+� ��7��6 (parent-child/base-derived)
4.
���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ���� ��� �Kc���� d� ��� ����������� ( MVC St r uct ur e Tut or i al i n ( MVC St r uct ur e Tut or i al i n ( MVC St r uct ur e Tut or i al i n ( MVC St r uct ur e Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#������"#������"#������"#����� %��%��%��%��
��!� ��8 ������� ���'�� �� MVC Structure (&�� ���!� �!"��� ������ �� �e�6) %��� %�( ��&�'���6 &�?����D6�E� "�� ���'� �6 ��� ��! ��� ,6 01.<?php 02.include "common-libs.php"; 03.include "config.php"; 04.mysql_connect($hostname, $username, $password); 05.mysql_select_db($database); 06.?> 07.<?php include "header.php"; ?> 08.<h1>Home Page</h1> 09.<?php 10.$sql = "SELECT * FROM news"; 11.$result = mysql_query($sql); 12.?> 13.<table> 14.<?php 15.while ($row = mysql_fetch_assoc($result)) { 16.?> 17.<tr> 18.<td><?php echo $row['date_created']; ?></td> 19.<td><?php echo $row['title']; ?></td> 20.</tr> 21.<?php 22.} 23.?> 24.</table> 25.<?php include "footer.php"; ?> &���� ��! ����� ���6s�6 &� ��! �+�:� ��� �� %��!� ��� �6���: �� �R� ,�� 3�� ������ ����।��!� ��8 ��������!"��� ������ &� ������ ���@�� ���� &���2।&� MVC Structure ��!(����� H ���( ��( ��� ���� ����@� :� ��j ��" ��&���� � ���� 3�� &���� ��!(��� ����� ��" ,��।&� ��( HA ,�
��!� (Model)
��8 (View)
������� (Controller)
���� ���� ���� ���� ( MODEL) :( MODEL) :( MODEL) :( MODEL) : @��� %��� ��!�(������� ��! ���� ���� &��� &�?���� D6�E ���6�2�,&� &�?������ �� ��!(���� ��@� ��!� ���� ��@���` p��!(��� (� �� ���6 ����� ��"�(��� �� �����(���) ���� 3���!(���� ]��� %��� !������ !�� ����� ,�!���,%��!� �6���:�����।� ��n ��!� ��� %���� !�� ���'�� ���.�"� ����।&� ��"�(����� ��� ,� ��"��� ��"� (business logic)
��� ��� ��� ��� ( VI EW) :( VI EW) :( VI EW) :( VI EW) :
&���� p ��I ��!(��� ���� 3(���� ]��� �8"�� &��� �" :���।� ��n &�� &��� ��@��� #��� �" �� ���6 ����� &�'A&�&�
�"।���!�(������� &���� &��� ��"� &��� ���# ���6 ���� 3�� ��"� ,!��,�� ���,%�&�&� �" � ���:।
�Kc���� �Kc���� �Kc���� �Kc���� ( CONTROLLER) :( CONTROLLER) :( CONTROLLER) :( CONTROLLER) :
�������� p ��I ��!(��� ���� 3�� ]��� ��!� &�� ��8 &� ��"�(��� &�� ����� ��� 3�(��3�( ����।� ��n ��!� &�� ��8
������ ��" ���� &� ��"�(��� &���� ��� ,�� ���।
��!�(������ O�#��� MVC � ��n ��!� ��8 ������� ���'�� &� ���o ��� ��" ��� � ��n &���� &���� ��! ��� ,��
���।
5.
0 ���a4����� ���4����0 ���a4����� ���4����0 ���a4����� ���4����0 ���a4����� ���4���� �2 �4b� �2 �4b� �2 �4b� �2 �4b� ( CodeI gni t er Downl oad & I nst al l ( CodeI gni t er Downl oad & I nst al l ( CodeI gni t er Downl oad & I nst al l ( CodeI gni t er Downl oad & I nst al l Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a)Tut or i al i n Bangl a) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
. �� http://codeigniter.com/downloads/&��� �� ��!�(������ O�#$�� A !�8����! ����, &A .zip format & ��� &�� %��"� ���� &�� %���� #�$� ��� ��� %����! ����,3�,6� %��� ����� �����6 ��" ��� :���- 6�� &���� ��� �� ,�-htdocs folder,&A ����� &� ������� F:\Program Files\xampp\htdocs. &A C Drive & ��� %��� �����6 C
drive &� ��� F �:�$�2 6�� F :���-।%���� �����6 :��� &� ������� C:\Program Files\xampp\htdocs. &���� &��!�8����!�b 6 (&�� %��"��b 6) ��x��A %����! � ��n ��� ��� �� ���� %� @��� ��x��A� ��� �:��� CodeIgniter.
&�� ��!�(������ ��x��A ����� &�� system>>application>> config>>config.php ����A ���J�K ���� &�!�
����। view source print? 01.|----------------------------------------------- --------------------------- 02.| Base Site URL 03.|----------------------------------------------- --------------------------- 04. 05. 06.$config['base_url'] = " http://localhost/CodeIgniter/ "; 07. 08. 09. 10. 11.|----------------------------------------------- --------------------------- 12.| Index File 13.|----------------------------------------------- --------------------------- 14. 15. 16.$config['index_page'] = "index.php"; 17. 18. 19. 20. 21.|----------------------------------------------- --------------------------- 22.| Default Language 23.|----------------------------------------------- --------------------------- 24. 25. 26.$config['language'] = "english"; 27. 28. 29. 30. 31.|----------------------------------------------- --------------------------- 32.| Default Character Set 33.|----------------------------------------------- --------------------------- 34. 35.
36.$config['charset'] = "UTF-8"; 37. 38. 39. 40. 41.|----------------------------------------------- --------------------------- 42.| Cache Directory Path 43.|----------------------------------------------- --------------------------- 44. 45. 46.$config['cache_path'] = ' http://127.0.0.1/codeigniter/cache/ '; 47. 48. 49. 50. 51.|----------------------------------------------- --------------------------- 52.| Session Variables 53.|----------------------------------------------- --------------------------- 54. 55. 56.$config['sess_cookie_name'] = 'ci_session'; 57.$config['sess_expiration'] = 7200; 58.$config['sess_encrypt_cookie'] = FALSE; 59.$config['sess_use_database'] = FALSE; 60.$config['sess_table_name'] = 'ci_sessions'; 61.$config['sess_match_ip'] = FALSE; 62.$config['sess_match_useragent'] = TRUE; 63.$config['sess_time_to_update'] = 300; 64. 65. 66. 67. 68.|----------------------------------------------- --------------------------- 69.| Global XSS Filtering 70.|----------------------------------------------- --------------------------- 71. 72. 73.$config['global_xss_filtering'] = FALSE; 74. 75. 76. 77. 78.|----------------------------------------------- --------------------------- 79.| Output Compression
80.|----------------------------------------------- --------------------------- 81. 82. 83.$config['compress_output'] = TRUE; 84. 85. 86. 87. 88.|----------------------------------------------- --------------------------- 89.| Rewrite PHP Short Tags 90.|----------------------------------------------- --------------------------- 91. 92. 93.$config['rewrite_short_tags'] = FALSE;
6.
0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� 0 ���a4����� 4�1a�� �� ( CodeI gni t er Conf i gur e Tut or i al i n ( CodeI gni t er Conf i gur e Tut or i al i n ( CodeI gni t er Conf i gur e Tut or i al i n ( CodeI gni t er Conf i gur e Tut or i al i n Bangl a)Bangl a)Bangl a)Bangl a) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
&��� 3���� “config.php” ����A �2� #���� database.php ���� &��� ���� %�2 �A 3���� &�!��� ����� &�� ���'� �6
����(�� ����। 01.$active_group = "default"; 02.$active_record = TRUE; 03. 04. 05.$db['default']['hostname'] = "localhost"; 06.$db['default']['username'] = "root"; 07.$db['default']['password'] = "mypassword"; 08.$db['default']['database'] = "mydatabase"; 09.$db['default']['dbdriver'] = "mysql"; 10.$db['default']['dbprefix'] = ""; 11.$db['default']['pconnect'] = TRUE; 12.$db['default']['db_debug'] = TRUE; 13.$db['default']['cache_on'] = FALSE; 14.$db['default']['cachedir'] = ""; 15.$db['default']['char_set'] = "utf8"; 16.$db['default']['dbcollat'] = "utf8_general_ci";
&��� address bar & http://localhost/CodeIgniter/ ���� &��� �:� ���'� �6 %��� � ��n ������� ���� �; ,�।
7.
0 ���a4����� � Wg� ��h� 34 ij�k 0 ���a4����� � Wg� ��h� 34 ij�k 0 ���a4����� � Wg� ��h� 34 ij�k 0 ���a4����� � Wg� ��h� 34 ij�k ( Cr eat i ng Fi r st ( Cr eat i ng Fi r st ( Cr eat i ng Fi r st ( Cr eat i ng Fi r st Appl i cat i on wi t h Appl i cat i on wi t h Appl i cat i on wi t h Appl i cat i on wi t h CodeI gni t er )CodeI gni t er )CodeI gni t er )CodeI gni t er ) ������������ ��������: �"#$�����"#$�����"#$�����"#$���� %��%��%��%��
@�� ���- %��� &� A8�������� �u�� %�( OOP &�� OOPHP &� A8��������(��� ��� &���2� 6� ��,�� &�� ��7�6��������।���"X �������! .�/���� &� ��� ��!�(�������� &��� ���� %�2 %�(� A8�������(��� ��� %��� 6�# ��7�6
������,6�� ��� ����* �� R� %�2। ��!�(������ MVC Structure &� ���o ��� ��! ���� ����@� :�,&�6 ��� #��� &�?���� D6�E ��� ��� �," ,�� 3�� ����&� �e�6 ��"��� ��"� (��!� ����� ��!(���),&�?���� ��"� (������� ����� ��!(���)&�� ��"���� ��"� (��8 �������!(���) �� %��:� %��:� ��� ����।3�� ,�� &�� &�?���� D6�E� ��$।&��� 2�� &�?���� D6�E ��� :���-।&� &�?����� ��@�
������� &�� ��8 &� ���,�� ��� ,��।&���� ��� !������� ��" �� 6�� ��!� &�# ��" ��। F:\Program Files\xampp\htdocs\CodeIgniter\system\application\controllers &� ������� �(�$ &���helloworld.php ����� ���� D6�E ����(F &� "�$(�$ C ,�� %����) &� ����A ����� &�!��� ����� 3�� ������!++ &���� &��� class D6�E ���� &�� ���'� �6 ����� 01.<?php 02.class HelloWorld extends Controller{ 03.function HelloWorld(){ 04.// load controller parent 05.parent::Controller();
06.} 07.function index(){ 08.$data['title']='My first application created wit h Code Igniter'; 09.$data['message']='Hello world!'; 10.// load 'helloworld' view 11.$this->load->view('helloworld',$data); 12.} 13.} 14.?>
������: ������� ���� :��� &��� �6� � L�� D6�E ��� ,���2 &�� ,�- ���L��/.�6���:6 L��/���� L�� 3�� ��� L�� 'Controller' �� �� ��� ,���2।&� 'Controller' L��A ��!�(������ %�( ��� D6�E ��� ����2 &�� ,�- �� L��/������ L��।&� ������L�� 'Controller' �� extends ��#��! A �:�� ���L�� 'HellowWorld' �� ��� ,���2 �� ���6 ����� .�6��:� ��� ,���2(derived).
&��� parent::Controller() &�� function index() ]��� ��&�'�� � ��� ,�- 6� �� ������ L��� (Controller &) 3�#&�� index() � ! (�����) �� �� ��।6���� . �6 ��2� !�� i� ����� ,���2 $data �������� (�����) &�� �]6E�6 ��8
���?�� &� !�� ��S��� ��� ,���2 3� �+�?���� ��� 'helloworld.php'।কোডইগনাইটারে loader ���� &��� L��
%�2,�������� &��� �6� � L�� D6�E ����� &� loader L�� ������A� 6�� ��� ��� �!�v '�� %��।&�� ��!�(������ &�loader L��A ����,�� ���� ��8 ����A ��! ���� "��।���!�� ����6 ,� &����
$this->load->view('helloworld',$data);
&�� ����c ��8 ����A ��! ��� &�� !��(��� &���� pass ��� :� 3�� =�8"��� :����।��8 ����A D6�E ���� &����
F:\Program Files\xampp\htdocs\CodeIgniter\system\application\views &� �(�$ helloworld.php ����� &��� ���� D6�E ����।����A ���� ����� 1.<html> 2.<head> 3.<title><?php echo $title;?></title> 4.</head> 5.<body> 6.<h1><?php echo $message?></h1> 7.</body> 8.</html>
&�� Address bar & ����� &�� &��� �:�। http://localhost/CodeIgniter/index.php/helloworld
A��: Controller &�� Views folder & 3 �5�� welcome.php &�� welcome_message.php ����:�A
������!++ & ���� :��� ���� ��2� ����6 �����।