'Programming'에 해당되는 글 1808건

  1. 2017.01.03 php foreach / array
  2. 2017.01.03 php "str"과 'str' 차이점 2
  3. 2017.01.02 php class 그리고.. 구조체가 없다?
  4. 2017.01.02 php 변수 스코프
  5. 2017.01.02 php print_r
  6. 2016.12.30 python smtplib의 신비..?
  7. 2016.12.28 php 게시판
  8. 2016.12.28 php db connection pool
  9. 2016.12.27 php 로그인 예제 2
  10. 2016.12.19 MFC / stdlib / qsort example
Programming/php2017. 1. 3. 11:23

배열 초기화 방법


$array['foo'] = "bar";

$array['bar'] = "foor";

[링크 : http://blogchannel.tistory.com/110]


<?php

$array = array(

    "foo" => "bar",

    "bar" => "foo",

);


// as of PHP 5.4

$array = [

    "foo" => "bar",

    "bar" => "foo",

];

?> 

[링크 : http://php.net/manual/en/language.types.array.php]


var_dump() 는 일종의.. 디버깅용도로 볼수 있을려나?

[링크 : http://php.net/manual/en/function.var-dump.php]


foreach (array_expression as $value)

    statement

foreach (array_expression as $key => $value)

    statement 

[링크 : http://php.net/manual/en/control-structures.foreach.php]

[링크 : http://blog.habonyphp.com/entry/php-배열에만-동작하는-반복문-foreach문]

'Programming > php' 카테고리의 다른 글

php 로그인 관련 - 세션  (0) 2017.01.06
php pack / unpack  (0) 2017.01.04
php "str"과 'str' 차이점  (2) 2017.01.03
php class 그리고.. 구조체가 없다?  (0) 2017.01.02
php 변수 스코프  (0) 2017.01.02
Posted by 구차니
Programming/php2017. 1. 3. 10:25

간단하게 요약(?) 하자면

array에는 되도록이면 'a' 로 해서 확장없이 빠르게 처리하는게 유리할 듯?



echo $data["a"]    이 경우 "a" 안에 치환할게 있는지 검사후 그냥 문자열 "a" 로 인식합니다.

echo $data['a']     이 경우 'a' 는 문자열이므로 바로 $data 에서 index 가 'a' 인 값을 찾을 수 있습니다.

[링크 : http://www.technote.co.kr/php/technote1/board.php?board=study&command=body&no=138]


다음과 같이 더블쿼터의 경우 더블쿼터 안에 있는 문자열에서 변수 등 치환할 값이 있으면 

그를 치환하여 출력한다. 하지만 싱글쿼터의 경우에는 치환할 값을 찾지 않고 그대로 값을 출력한다. 

[링크 : http://luckyyowu.tistory.com/61]


Single quoted

The simplest way to specify a string is to enclose it in single quotes (the character ').

To specify a literal single quote, escape it with a backslash (\). To specify a literal backslash, double it (\\). All other instances of backslash will be treated as a literal backslash: this means that the other escape sequences you might be used to, such as \r or \n, will be output literally as specified rather than having any special meaning.

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.syntax.single]


Double quoted

If the string is enclosed in double-quotes ("), PHP will interpret the following escape sequences for special characters:

As in single quoted strings, escaping any other character will result in the backslash being printed too. Before PHP 5.1.1, the backslash in \{$var} had not been printed.

The most important feature of double-quoted strings is the fact that variable names will be expanded. See string parsing for details.

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double]


<?php

$juice = "apple";


echo "He drank some $juice juice.".PHP_EOL;

// Invalid. "s" is a valid character for a variable name, but the variable is $juice.

echo "He drank some juice made of $juices.";

// Valid. Explicitly specify the end of the variable name by enclosing it in braces:

echo "He drank some juice made of ${juice}s."

?>


He drank some apple juice.

He drank some juice made of .

He drank some juice made of apples. 

[링크 : http://php.net/manual/en/language.types.string.php]

[링크 : http://php.net/manual/en/language.types.string.php#language.types.string.parsing]

'Programming > php' 카테고리의 다른 글

php pack / unpack  (0) 2017.01.04
php foreach / array  (0) 2017.01.03
php class 그리고.. 구조체가 없다?  (0) 2017.01.02
php 변수 스코프  (0) 2017.01.02
php print_r  (0) 2017.01.02
Posted by 구차니
Programming/php2017. 1. 2. 09:33

->는 구조체가 아니라 클래스에 쓰는 애라..

[링크 : http://php.net/manual/kr/language.oop5.php]

    [링크 : http://php.net/manual/kr/language.oop5.constants.php]


그리고 구조체는 없으니까 array로 대체해서 쓰던가 말던가?!!

[링크 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=qna_function&wr_id=313395]



php관련 예제들 중에 -> 나오면 일단 클래스 쓰고 있다고 보면 되겠군..

'Programming > php' 카테고리의 다른 글

php foreach / array  (0) 2017.01.03
php "str"과 'str' 차이점  (2) 2017.01.03
php 변수 스코프  (0) 2017.01.02
php print_r  (0) 2017.01.02
php 게시판  (0) 2016.12.28
Posted by 구차니
Programming/php2017. 1. 2. 09:18

음.. C로 치면 전역 변수로 쓰면

함수 내에서 반드시

$GLOBALS["var"]

이런식으로 불러와야 한다. 아구 귀찮아..


[링크 : http://php.net/manual/en/reserved.variables.globals.php]


아무튼 자매품(?)으로

$_GET

$_POST

$_SESSION 등이 있네

Table of Contents ¶

[링크 : http://php.net/manual/en/reserved.variables.php]

'Programming > php' 카테고리의 다른 글

php "str"과 'str' 차이점  (2) 2017.01.03
php class 그리고.. 구조체가 없다?  (0) 2017.01.02
php print_r  (0) 2017.01.02
php 게시판  (0) 2016.12.28
php db connection pool  (0) 2016.12.28
Posted by 구차니
Programming/php2017. 1. 2. 09:09

db에서 값을 불러오면 array로 읽히는데

print 하면 Array 라고만 나와서

내용을 편하게 보는 법을 찾아 보니.. 이런 애가 있었네?


[링크 : http://m.blog.naver.com/diceworld/220295811114]

[링크 : http://php.net/manual/en/function.print-r.php]

[링크 : http://blog.habonyphp.com/entry/php-배열을-읽기-편하게-출력해-주는-printr-함수]

'Programming > php' 카테고리의 다른 글

php class 그리고.. 구조체가 없다?  (0) 2017.01.02
php 변수 스코프  (0) 2017.01.02
php 게시판  (0) 2016.12.28
php db connection pool  (0) 2016.12.28
php 로그인 예제 2  (0) 2016.12.27
Posted by 구차니

어라?

파이썬으로 메일보내는데

새가

ㅅㅐ 로 보내지네.. 머지?


[링크 : http://unicode.scarfboy.com/?s=U%2BC0C8]

[링크 : http://unicode.scarfboy.com/?s=U%2b1109]

[링크 : http://unicode.scarfboy.com/?s=U%2b1162]



+

설정해도 안되고..

일단 ssh에서 직접 스크립트를 실행하면 한글이 안깨지고 가는데..

svn 통해서 hook 실행되면 깨진다.

[링크 : https://mikewest.org/2006/06/subversion-post-commit-hooks-101]

[링크 : http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks]

'Programming > python(파이썬)' 카테고리의 다른 글

파이썬 type 확인하기  (0) 2017.04.02
python sqlite3  (0) 2017.03.30
python이 인기라는데..  (0) 2014.03.19
python2 vs python3  (0) 2013.01.02
PyOpenGL  (0) 2011.10.04
Posted by 구차니
Programming/php2016. 12. 28. 18:59

'Programming > php' 카테고리의 다른 글

php 변수 스코프  (0) 2017.01.02
php print_r  (0) 2017.01.02
php db connection pool  (0) 2016.12.28
php 로그인 예제 2  (0) 2016.12.27
php pdo? - PHP Data Object  (0) 2016.11.23
Posted by 구차니
Programming/php2016. 12. 28. 18:30

'Programming > php' 카테고리의 다른 글

php print_r  (0) 2017.01.02
php 게시판  (0) 2016.12.28
php 로그인 예제 2  (0) 2016.12.27
php pdo? - PHP Data Object  (0) 2016.11.23
php template  (0) 2016.11.14
Posted by 구차니
Programming/php2016. 12. 27. 10:30

'Programming > php' 카테고리의 다른 글

php 게시판  (0) 2016.12.28
php db connection pool  (0) 2016.12.28
php pdo? - PHP Data Object  (0) 2016.11.23
php template  (0) 2016.11.14
php 버전 및 년도  (0) 2016.10.11
Posted by 구차니
Programming/C Win32 MFC2016. 12. 19. 09:18

심심해서 만든 로또 프로그램에 정렬기능 추가

qsort()는 첨 써보네..

일단 compare 함수에서 캐스팅 하는 부분을 잘 해주면...

범용으로 쓸수 있을려나? 무리일려나?


int compare (const void *first, const void *second)

{

    if (*(unsigned char*)first > *(unsigned char*)second)

        return 1;

    else if (*(unsigned char*)first < *(unsigned char*)second)

        return -1;

    else 

        return 0;

}


void CLottoDlg::OnButton1() 

{

// TODO: Add your control notification handler code here

int idx;

unsigned char flag[45];

unsigned char genval = 0;

CString *strarray[42] =

{

&m_edit1,&m_edit2,&m_edit3,&m_edit4,&m_edit5,&m_edit6,

&m_edit7,&m_edit8,&m_edit9,&m_edit10,&m_edit11,&m_edit12,

&m_edit13,&m_edit14,&m_edit15,&m_edit16,&m_edit17,&m_edit18,

&m_edit19,&m_edit20,&m_edit21,&m_edit22,&m_edit23,&m_edit24,

&m_edit25,&m_edit26,&m_edit27,&m_edit28,&m_edit29,&m_edit30,

&m_edit31,&m_edit32,&m_edit33,&m_edit34,&m_edit35,&m_edit36,

&m_edit37,&m_edit38,&m_edit39,&m_edit40,&m_edit41,&m_edit42

};


unsigned char row[42];

memset(flag, 0x00, sizeof(unsigned char) * 45);

srand(time(NULL));


for(idx = 0 ;idx < 30;idx++)

{

do

{

genval = rand() % 45;

}

while(flag[genval] != 0);

flag[genval] = 1;

row[idx] = genval;

}


for(idx = 0; idx < 5; idx++)

{

qsort(row + (idx * 6), 6, sizeof(char), compare);

}


for(idx = 0; idx < 30; idx++)

{

strarray[idx]->Format("%d",row[idx] + 1);

}


UpdateData(FALSE);


lotto.zip


'Programming > C Win32 MFC' 카테고리의 다른 글

MFC HTTP GET/POST  (0) 2017.03.02
win32 http 인증 관련  (0) 2017.02.28
MFC UpdateData()  (0) 2016.12.16
윈도우에서 dll 동적 라이브러리 사용하기  (0) 2016.04.04
가변 매크로 __VA_ARGS__  (0) 2016.03.18
Posted by 구차니